/**
 * Layout System
 * Grid, Flexbox, Container utilities and responsive breakpoints
 * 
 * @package OGULCAN_Theme
 * @requirements 2.1, 2.2, 2.4, 2.5
 */

/* ==========================================================================
   Container System
   ========================================================================== */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-md);
    padding-right: var(--space-md);
}

.container--narrow {
    max-width: var(--container-narrow);
}

.container--wide {
    max-width: var(--container-wide);
}

.container--fluid {
    max-width: 100%;
}

/* ==========================================================================
   CSS Grid System
   Requirements: 2.1 - CSS Grid for portfolio and content layouts
   ========================================================================== */

.grid {
    display: grid;
    gap: var(--grid-gap);
}

/* Grid columns - auto-fit responsive */
.grid--auto {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

/* Fixed column grids */
.grid--2 {
    grid-template-columns: repeat(1, 1fr);
}

.grid--3 {
    grid-template-columns: repeat(1, 1fr);
}

.grid--4 {
    grid-template-columns: repeat(1, 1fr);
}

/* Grid gap variations */
.grid--gap-sm {
    gap: var(--grid-gap-sm);
}

.grid--gap-lg {
    gap: var(--grid-gap-lg);
}

.grid--gap-none {
    gap: 0;
}

/* Grid alignment */
.grid--center {
    justify-items: center;
    align-items: center;
}

.grid--start {
    justify-items: start;
    align-items: start;
}

.grid--end {
    justify-items: end;
    align-items: end;
}

/* ==========================================================================
   Flexbox System
   Requirements: 2.2 - Flexbox for component-level alignments
   ========================================================================== */

.flex {
    display: flex;
}

.flex--inline {
    display: inline-flex;
}

/* Flex direction */
.flex--row {
    flex-direction: row;
}

.flex--col {
    flex-direction: column;
}

.flex--row-reverse {
    flex-direction: row-reverse;
}

.flex--col-reverse {
    flex-direction: column-reverse;
}

/* Flex wrap */
.flex--wrap {
    flex-wrap: wrap;
}

.flex--nowrap {
    flex-wrap: nowrap;
}

/* Justify content (main axis) */
.flex--justify-start {
    justify-content: flex-start;
}

.flex--justify-end {
    justify-content: flex-end;
}

.flex--justify-center {
    justify-content: center;
}

.flex--justify-between {
    justify-content: space-between;
}

.flex--justify-around {
    justify-content: space-around;
}

.flex--justify-evenly {
    justify-content: space-evenly;
}

/* Align items (cross axis) */
.flex--align-start {
    align-items: flex-start;
}

.flex--align-end {
    align-items: flex-end;
}

.flex--align-center {
    align-items: center;
}

.flex--align-baseline {
    align-items: baseline;
}

.flex--align-stretch {
    align-items: stretch;
}

/* Common flex patterns */
.flex--center {
    justify-content: center;
    align-items: center;
}

.flex--between-center {
    justify-content: space-between;
    align-items: center;
}

/* Flex gap */
.flex--gap-xs {
    gap: var(--space-xs);
}

.flex--gap-sm {
    gap: var(--space-sm);
}

.flex--gap-md {
    gap: var(--space-md);
}

.flex--gap-lg {
    gap: var(--space-lg);
}

.flex--gap-xl {
    gap: var(--space-xl);
}

/* Flex item utilities */
.flex-grow {
    flex-grow: 1;
}

.flex-shrink-0 {
    flex-shrink: 0;
}

.flex-1 {
    flex: 1 1 0%;
}

.flex-auto {
    flex: 1 1 auto;
}

.flex-none {
    flex: none;
}

/* ==========================================================================
   Section Spacing
   ========================================================================== */

.section {
    padding-top: var(--space-3xl);
    padding-bottom: var(--space-3xl);
}

.section--sm {
    padding-top: var(--space-2xl);
    padding-bottom: var(--space-2xl);
}

.section--lg {
    padding-top: var(--space-4xl);
    padding-bottom: var(--space-4xl);
}

.section--xl {
    padding-top: var(--space-5xl);
    padding-bottom: var(--space-5xl);
}

/* ==========================================================================
   Spacing Utilities
   ========================================================================== */

/* Margin utilities */
.m-0 { margin: 0; }
.m-auto { margin: auto; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-auto { margin-top: auto; margin-bottom: auto; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.ml-0 { margin-left: 0; }
.mr-0 { margin-right: 0; }

.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mt-xl { margin-top: var(--space-xl); }
.mt-2xl { margin-top: var(--space-2xl); }

.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.mb-xl { margin-bottom: var(--space-xl); }
.mb-2xl { margin-bottom: var(--space-2xl); }

/* Padding utilities */
.p-0 { padding: 0; }
.p-sm { padding: var(--space-sm); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }
.p-xl { padding: var(--space-xl); }

.px-sm { padding-left: var(--space-sm); padding-right: var(--space-sm); }
.px-md { padding-left: var(--space-md); padding-right: var(--space-md); }
.px-lg { padding-left: var(--space-lg); padding-right: var(--space-lg); }

.py-sm { padding-top: var(--space-sm); padding-bottom: var(--space-sm); }
.py-md { padding-top: var(--space-md); padding-bottom: var(--space-md); }
.py-lg { padding-top: var(--space-lg); padding-bottom: var(--space-lg); }

/* ==========================================================================
   Width & Height Utilities
   ========================================================================== */

.w-full { width: 100%; }
.w-auto { width: auto; }
.w-screen { width: 100vw; }

.h-full { height: 100%; }
.h-auto { height: auto; }
.h-screen { height: 100vh; }

.min-h-screen { min-height: 100vh; }

/* ==========================================================================
   Position Utilities
   ========================================================================== */

.relative { position: relative; }
.absolute { position: absolute; }
.fixed { position: fixed; }
.sticky { position: sticky; }

.inset-0 {
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
}

/* ==========================================================================
   Display Utilities
   ========================================================================== */

.block { display: block; }
.inline-block { display: inline-block; }
.inline { display: inline; }
.hidden { display: none; }

/* ==========================================================================
   Text Alignment
   ========================================================================== */

.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ==========================================================================
   Overflow
   ========================================================================== */

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-scroll { overflow: scroll; }

/* ==========================================================================
   Responsive Breakpoints - Mobile First
   Requirements: 2.4, 2.5 - Mobile-first responsive design with min-width
   ========================================================================== */

/* Small devices (landscape phones, 576px and up) */
@media (min-width: 576px) {
    .container {
        padding-left: var(--space-lg);
        padding-right: var(--space-lg);
    }
    
    /* Grid responsive */
    .grid--2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Responsive display */
    .sm\:block { display: block; }
    .sm\:hidden { display: none; }
    .sm\:flex { display: flex; }
    
    /* Responsive flex direction */
    .sm\:flex--row { flex-direction: row; }
    .sm\:flex--col { flex-direction: column; }
    
    /* Responsive text alignment */
    .sm\:text-left { text-align: left; }
    .sm\:text-center { text-align: center; }
    .sm\:text-right { text-align: right; }
}

/* Medium devices (tablets, 768px and up) */
@media (min-width: 768px) {
    .container {
        padding-left: var(--space-xl);
        padding-right: var(--space-xl);
    }
    
    /* Grid responsive */
    .grid--3 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid--4 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Section spacing adjustments */
    .section {
        padding-top: var(--space-4xl);
        padding-bottom: var(--space-4xl);
    }
    
    .section--lg {
        padding-top: var(--space-5xl);
        padding-bottom: var(--space-5xl);
    }
    
    /* Responsive display */
    .md\:block { display: block; }
    .md\:hidden { display: none; }
    .md\:flex { display: flex; }
    
    /* Responsive flex direction */
    .md\:flex--row { flex-direction: row; }
    .md\:flex--col { flex-direction: column; }
    
    /* Responsive text alignment */
    .md\:text-left { text-align: left; }
    .md\:text-center { text-align: center; }
    .md\:text-right { text-align: right; }
    
    /* Responsive margins */
    .md\:mt-0 { margin-top: 0; }
    .md\:mb-0 { margin-bottom: 0; }
    .md\:mx-auto { margin-left: auto; margin-right: auto; }
}

/* Large devices (desktops, 992px and up) */
@media (min-width: 992px) {
    /* Grid responsive */
    .grid--3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid--4 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Responsive display */
    .lg\:block { display: block; }
    .lg\:hidden { display: none; }
    .lg\:flex { display: flex; }
    
    /* Responsive flex direction */
    .lg\:flex--row { flex-direction: row; }
    .lg\:flex--col { flex-direction: column; }
    
    /* Responsive text alignment */
    .lg\:text-left { text-align: left; }
    .lg\:text-center { text-align: center; }
    .lg\:text-right { text-align: right; }
}

/* Extra large devices (large desktops, 1200px and up) */
@media (min-width: 1200px) {
    /* Grid responsive */
    .grid--4 {
        grid-template-columns: repeat(4, 1fr);
    }
    
    /* Responsive display */
    .xl\:block { display: block; }
    .xl\:hidden { display: none; }
    .xl\:flex { display: flex; }
    
    /* Responsive flex direction */
    .xl\:flex--row { flex-direction: row; }
    .xl\:flex--col { flex-direction: column; }
    
    /* Responsive text alignment */
    .xl\:text-left { text-align: left; }
    .xl\:text-center { text-align: center; }
    .xl\:text-right { text-align: right; }
}

/* Extra extra large devices (1400px and up) */
@media (min-width: 1400px) {
    .container--wide {
        max-width: 1600px;
    }
    
    /* Responsive display */
    .xxl\:block { display: block; }
    .xxl\:hidden { display: none; }
    .xxl\:flex { display: flex; }
}

/* ==========================================================================
   Portfolio Grid (Specific Layout)
   Requirements: 2.1 - CSS Grid for portfolio layouts
   ========================================================================== */

.portfolio-grid {
    display: grid;
    gap: var(--grid-gap);
    grid-template-columns: repeat(1, 1fr);
}

@media (min-width: 576px) {
    .portfolio-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 992px) {
    .portfolio-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Portfolio grid with featured item */
.portfolio-grid--featured {
    display: grid;
    gap: var(--grid-gap);
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .portfolio-grid--featured {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .portfolio-grid--featured .portfolio-card:first-child {
        grid-column: span 2;
    }
}

@media (min-width: 992px) {
    .portfolio-grid--featured {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .portfolio-grid--featured .portfolio-card:first-child {
        grid-column: span 2;
        grid-row: span 2;
    }
}

/* ==========================================================================
   CSS Grid Fallback for older browsers
   ========================================================================== */

@supports not (display: grid) {
    .grid,
    .portfolio-grid {
        display: flex;
        flex-wrap: wrap;
        margin: calc(var(--grid-gap) / -2);
    }
    
    .grid > *,
    .portfolio-grid > * {
        flex: 1 1 280px;
        margin: calc(var(--grid-gap) / 2);
    }
}
