/*
 * CurlForge — Layout Styles
 * Structural positioning, grid, responsive breakpoints.
 * Separate from component styles and theme variables.
 */

/* Alpine.js cloak: hide elements until Alpine initializes */
[x-cloak] { display: none !important; }

/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--cf-font-size-base);
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: var(--cf-font-sans);
    line-height: var(--cf-line-height);
    color: var(--cf-text);
    background: var(--cf-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }
a { color: var(--cf-primary); text-decoration: none; }
a:hover { color: var(--cf-primary-hover); }

/* === Container === */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.container-narrow {
    max-width: 800px;
}

/* === Main Content === */
.site-main {
    flex: 1;
    padding-bottom: 2rem;
}

/* Add space for mobile nav */
@media (max-width: 767px) {
    .site-main {
        padding-bottom: calc(var(--cf-mobile-nav-height) + 1rem);
    }
}

/* === Header === */
.site-header {
    background: var(--cf-header-bg);
    height: var(--cf-header-height);
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 2px solid var(--cf-header-accent);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--cf-header-text-hover);
    font-weight: 700;
    font-size: 1.15rem;
    text-decoration: none;
    white-space: nowrap;
}

.header-logo:hover {
    color: var(--cf-header-accent);
}

.header-logo svg {
    width: 32px;
    height: 32px;
    fill: var(--cf-header-accent);
    flex-shrink: 0;
}

/* Desktop nav */
.header-nav {
    display: none;
    align-items: center;
    gap: 0.25rem;
    list-style: none;
}

.header-nav a {
    color: var(--cf-header-text);
    padding: 0.5rem 0.875rem;
    border-radius: var(--cf-radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    transition: color 0.15s, background 0.15s;
    text-decoration: none;
}

.header-nav a:hover,
.header-nav a.active {
    color: var(--cf-header-text-hover);
    background: rgba(255,255,255,0.08);
}

.header-nav a.active {
    border-bottom: 2px solid var(--cf-header-accent);
}

@media (min-width: 768px) {
    .header-nav { display: flex; }
}

/* === Mobile Bottom Nav === */
.mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    background: var(--cf-mobile-nav-bg);
    height: var(--cf-mobile-nav-height);
    border-top: 1px solid rgba(255,255,255,0.1);
    align-items: stretch;
    justify-content: space-around;
}

.mobile-nav a {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--cf-mobile-nav-text);
    font-size: 0.65rem;
    font-weight: 500;
    text-decoration: none;
    gap: 0.2rem;
    transition: color 0.15s;
    padding: 0.25rem 0;
}

.mobile-nav a svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.mobile-nav a:hover,
.mobile-nav a.active,
.mobile-nav-more:hover,
.mobile-nav-more.active {
    color: var(--cf-mobile-nav-active);
}

/* "More" button shares the tab visual style */
.mobile-nav-more {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    background: none;
    border: 0;
    color: var(--cf-mobile-nav-text);
    font-size: 0.65rem;
    font-weight: 500;
    gap: 0.2rem;
    padding: 0.25rem 0;
    cursor: pointer;
    font-family: inherit;
}
.mobile-nav-more svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

/* Slide-up "More" panel */
.mobile-nav-more-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}
.mobile-nav-more-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
    background: var(--cf-bg-card, #fff);
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.2);
    padding: 0.5rem 0.75rem calc(1rem + env(safe-area-inset-bottom));
    max-height: 80vh;
    overflow-y: auto;
}
.mobile-nav-more-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--cf-border, #e9ecef);
    font-weight: 600;
    color: var(--cf-text, #212529);
}
.mobile-nav-more-header button {
    background: none;
    border: 0;
    padding: 0.25rem;
    color: var(--cf-text-muted, #6c757d);
    cursor: pointer;
}
.mobile-nav-more-header button svg { fill: currentColor; }
.mobile-nav-more-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
    padding: 0.75rem 0.25rem;
}
.mobile-nav-more-list a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 0.75rem 0.25rem;
    background: var(--cf-bg, #f8f9fa);
    border-radius: var(--cf-radius, 8px);
    text-decoration: none;
    color: var(--cf-text, #212529);
    font-size: 0.75rem;
    text-align: center;
}
.mobile-nav-more-list a svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}
.mobile-nav-more-list a.active {
    background: var(--cf-primary, #c0392b);
    color: #fff;
}

@media (min-width: 768px) {
    .mobile-nav { display: none; }
    .mobile-nav-more-backdrop,
    .mobile-nav-more-panel { display: none !important; }
}

[x-cloak] { display: none !important; }

/* === Footer === */
.site-footer {
    background: var(--cf-header-bg);
    color: var(--cf-header-text);
    padding: 2rem 0;
    margin-top: auto;
    font-size: 0.875rem;
}

.footer-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
}

.footer-powered {
    color: var(--cf-gray-500);
    font-size: 0.8rem;
}

@media (max-width: 767px) {
    .site-footer {
        padding-bottom: calc(var(--cf-mobile-nav-height) + 2rem);
    }
    .footer-inner {
        flex-direction: column;
        text-align: center;
    }
}

/* === Page Section === */
.page-section {
    padding: 3rem 0;
}

.page-section:nth-child(even) {
    background: var(--cf-bg-alt);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.section-title {
    font-family: var(--cf-font-heading);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--cf-text);
}

.section-link {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--cf-primary);
}

/* === Grid Layouts === */
.grid {
    display: grid;
    gap: 1.5rem;
}

.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr; }

@media (min-width: 640px) {
    .grid-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
    .grid-4 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
    .grid-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-4 { grid-template-columns: repeat(4, 1fr); }
}
