/* =========================================================================
   Metro AI Publishing Factory — Design System (app.css)
   Design tokens, base reset, typography, layout, decorative shapes.
   All colours live here as CSS variables (single point of change).
   ========================================================================= */

:root {
    /* Brand palette */
    --color-primary: #F6A800;
    --color-primary-hover: #DB9200;
    --color-secondary: #5BBEEB;
    --color-accent-mint: #68D5B5;
    --color-accent-purple: #8A78E8;

    /* Surfaces */
    --color-bg: #FFFDF7;
    --color-bg-soft: #FFF7DF;
    --color-card: #FFFFFF;

    /* Text */
    --color-text: #242424;
    --color-text-secondary: #6D6D6D;
    --color-border: #ECE9DF;

    /* Status */
    --color-success: #3CB878;
    --color-warning: #F5A623;
    --color-danger: #E45555;
    --color-info: #4299E1;

    /* Tinted status backgrounds */
    --bg-success: #E7F7EE;
    --bg-warning: #FDF1DA;
    --bg-danger: #FCE8E8;
    --bg-info: #E6F1FB;

    /* Typography */
    --font-heading: "Mitr", "Noto Sans Thai", sans-serif;
    --font-body: "Prompt", "Noto Sans Thai", sans-serif;
    --font-display: "Fredoka", "Prompt", "Noto Sans Thai", sans-serif;

    /* Radii */
    --radius-card: 20px;
    --radius-input: 14px;
    --radius-btn: 14px;
    --radius-sm: 12px;
    --radius-pill: 999px;

    /* Shadows (very light) */
    --shadow-sm: 0 1px 2px rgba(36, 36, 36, 0.05);
    --shadow-md: 0 6px 18px rgba(36, 36, 36, 0.06);
    --shadow-lg: 0 14px 40px rgba(36, 36, 36, 0.08);

    /* Spacing scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;

    /* Motion */
    --transition: 180ms ease;

    /* Layout */
    --container-max: 1120px;
    --header-height: 68px;
    --focus-ring: 0 0 0 3px rgba(246, 168, 0, 0.35);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: 16px;
    font-weight: 400;
    line-height: 1.6;
    color: var(--color-text);
    background-color: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

h1, h2, h3, h4 {
    font-family: var(--font-heading);
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text);
    margin: 0 0 var(--space-3);
}

h1 { font-size: 1.75rem; font-weight: 700; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.125rem; }

p { margin: 0 0 var(--space-3); }

a {
    color: var(--color-primary-hover);
    text-decoration: none;
}
a:hover { text-decoration: underline; }

code {
    font-family: ui-monospace, "Cascadia Code", Consolas, monospace;
}

img { max-width: 100%; display: block; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: var(--color-card);
    color: var(--color-text);
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-sm);
    z-index: 100;
}
.skip-link:focus {
    left: var(--space-3);
    top: var(--space-3);
    box-shadow: var(--shadow-md);
}

/* ---------- Layout primitives ---------- */

.container {
    width: 100%;
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-4);
}

.app-body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background:
        radial-gradient(1200px 400px at 100% -10%, var(--color-bg-soft), transparent 60%),
        var(--color-bg);
}

.app-main {
    flex: 1 0 auto;
    padding: var(--space-6) 0 var(--space-7);
}

.page-head {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: var(--space-4);
    margin-bottom: var(--space-6);
}
.page-head__title { margin: 0; }
.page-head__subtitle {
    color: var(--color-text-secondary);
    margin: var(--space-1) 0 0;
}

/* ---------- Header & navigation ---------- */

.app-header {
    position: sticky;
    top: 0;
    z-index: 40;
    background: rgba(255, 253, 247, 0.9);
    backdrop-filter: saturate(1.1) blur(8px);
    border-bottom: 1px solid var(--color-border);
}
.app-header__inner {
    max-width: var(--container-max);
    margin: 0 auto;
    padding: 0 var(--space-4);
    min-height: var(--header-height);
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    color: var(--color-text);
}
.brand:hover { text-decoration: none; }
.brand__mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    color: #fff;
    font-size: 1.25rem;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    box-shadow: var(--shadow-sm);
}
.brand__text { display: flex; flex-direction: column; line-height: 1.1; }
.brand__name { font-family: var(--font-heading); font-weight: 600; font-size: 1rem; }
.brand__tag { font-size: 0.72rem; color: var(--color-text-secondary); letter-spacing: 0.02em; }

.app-nav {
    display: flex;
    gap: var(--space-2);
    margin-left: var(--space-4);
}
.app-nav__link {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-pill);
    color: var(--color-text-secondary);
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
}
.app-nav__link:hover { background: var(--color-bg-soft); color: var(--color-text); text-decoration: none; }
.app-nav__link.is-active { background: var(--color-primary); color: #fff; }

.app-header__account {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: var(--space-3);
}
.account-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    color: var(--color-text-secondary);
    font-size: 0.9rem;
    max-width: 160px;
}
.account-chip__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.logout-form { margin: 0; }

.app-footer {
    flex-shrink: 0;
    text-align: center;
    padding: var(--space-5) var(--space-4);
    color: var(--color-text-secondary);
    font-size: 0.85rem;
    border-top: 1px solid var(--color-border);
}
.app-footer p { margin: 0; }

/* ---------- Auth layout ---------- */

.auth-body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: var(--space-5) var(--space-4);
    background:
        radial-gradient(700px 500px at 15% 10%, var(--color-bg-soft), transparent 55%),
        radial-gradient(600px 500px at 100% 100%, #EAF7FF, transparent 55%),
        var(--color-bg);
}
.auth-shell {
    position: relative;
    width: 100%;
    max-width: 960px;
}
.auth-main {
    position: relative;
    z-index: 2;
    display: grid;
    place-items: center;
}

/* Decorative organic shapes (own CSS, no external assets) */
.organic-shape {
    position: absolute;
    border-radius: 45% 55% 60% 40% / 50% 45% 55% 50%;
    filter: blur(2px);
    opacity: 0.5;
    z-index: 1;
    pointer-events: none;
}
.organic-shape--one { width: 220px; height: 220px; top: -60px; left: -40px; background: var(--color-accent-mint); }
.organic-shape--two { width: 160px; height: 160px; bottom: -50px; right: -30px; background: var(--color-secondary); }
.organic-shape--three { width: 120px; height: 120px; top: 40%; right: 10%; background: var(--color-accent-purple); opacity: 0.28; }

.page-fade { animation: fadeIn 240ms ease both; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* ---------- Utilities ---------- */
.text-secondary { color: var(--color-text-secondary); }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.stack > * + * { margin-top: var(--space-4); }
.is-hidden { display: none !important; }
.section-gap { margin-top: var(--space-6); }
.section-gap-sm { margin-top: var(--space-4); }
.age-custom { margin-top: var(--space-3); }
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0 0 0 0);
    white-space: nowrap; border: 0;
}
