/*
  HALIA Design Foundation — Phase A
  Layers (later = stronger): reset < tokens < base < legacy < components < pages.
  - legacy: existing style/community/home/identity CSS (wrapped in @layer legacy) keeps page layout.
  - components: shared HALIA parts; they win over legacy skin rules without specificity fights.
  Raw palette values are allowed only in this file's token blocks.
*/
@layer reset, tokens, base, legacy, components, pages;

@layer tokens {
  :root {
    color-scheme: light;

    /* Color — light */
    --bg-primary: #F4F7F8;
    --bg-secondary: #EEF3F4;
    --surface: #FFFFFF;
    --surface-hover: #F2F7F6;
    --surface-raised: #FFFFFF;
    --text-primary: #13233A;
    --text-secondary: #3F5064;
    --text-muted: #5A6B7B;
    --border-subtle: #E3EAED;
    --border-default: #C9D5DA;
    --border-strong: #8797A3;
    --accent: #145E57;
    --accent-hover: #0E4A45;
    --on-accent: #FFFFFF;
    --accent-subtle: #E3F1ED;
    --success: #1B7A4B;
    --success-subtle: #E3F3EA;
    --warning: #8A5A00;
    --warning-subtle: #FBF1DC;
    --danger: #BF2F4A;
    --danger-hover: #A5263E;
    --danger-subtle: #FBE7EB;
    --on-danger: #FFFFFF;
    --info: #2A67A8;
    --info-subtle: #E4EEF8;
    --focus-ring: #145E57;
    --overlay: rgba(10, 22, 32, .48);
    --header-surface: rgba(255, 255, 255, .96);
    --hero-veil: rgba(245, 248, 249, .91);
    --skeleton-base: #E6EDEF;
    --skeleton-shine: #F3F7F8;

    /* Typography */
    --font-sans: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
    --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Consolas, "Liberation Mono", monospace;
    --text-display: 700 40px/48px var(--font-sans);
    --text-h1: 700 28px/36px var(--font-sans);
    --text-h2: 650 20px/28px var(--font-sans);
    --text-h3: 600 17px/24px var(--font-sans);
    --text-body-lg: 400 16px/28px var(--font-sans);
    --text-body: 400 15px/24px var(--font-sans);
    --text-body-sm: 400 14px/20px var(--font-sans);
    --text-label: 600 14px/20px var(--font-sans);
    --text-caption: 500 12px/16px var(--font-sans);
    --tracking-display: -.02em;
    --tracking-h1: -.015em;
    --tracking-h2: -.01em;
    --tracking-caption: .01em;
    --tracking-overline: .06em;

    /* Spacing (4px grid) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;

    /* Shadow (floating layers only) */
    --shadow-1: 0 1px 2px rgba(10, 22, 32, .06);
    --shadow-2: 0 8px 24px rgba(10, 22, 32, .12), 0 2px 6px rgba(10, 22, 32, .06);
    --shadow-3: 0 24px 56px rgba(10, 22, 32, .20);

    /* Focus */
    --focus-width: 2px;
    --focus-offset: 2px;

    /* Motion (definitions only; broad application is Phase D) */
    --dur-instant: 80ms;
    --dur-fast: 150ms;
    --dur-normal: 200ms;
    --dur-slow: 280ms;
    --ease-standard: cubic-bezier(.2, 0, 0, 1);
    --ease-enter: cubic-bezier(0, 0, .2, 1);
    --ease-exit: cubic-bezier(.4, 0, 1, 1);

    /* Layering */
    --z-header: 20;
    --z-dropdown: 40;
    --z-toast: 70;
    --z-modal: 80;

    /* Control sizes */
    --control-sm: 32px;
    --control-md: 40px;
    --control-lg: 48px;
    --hit-min: 44px;
    /* Phase C: brand, mint surfaces, content tones and label colours (concept-sampled). */
    --brand-ink: #13233A;
    --brand-dot: #12806F;
    --accent-strong-start: #1B6E65;
    --accent-strong-end: #104F4A;
    --surface-mint: #EDF6F3;
    --surface-mint-strong: #DCEFE9;
    --surface-muted: #F6F9FA;
    --hero-sky: #E7F1F2;
    --hero-sky-end: #F4F8F6;
    --tone-green-bg: #E0F4EC; --tone-green-fg: #17704F;
    --tone-blue-bg: #E6EFFB; --tone-blue-fg: #2458A2;
    --tone-purple-bg: #EEEAFB; --tone-purple-fg: #5941A6;
    --tone-pink-bg: #FBE9F0; --tone-pink-fg: #A2365F;
    --tone-red-bg: #FDEBEB; --tone-red-fg: #B8322F;
    --tone-orange-bg: #FDF0E3; --tone-orange-fg: #9A4E0C;
    --tone-teal-bg: #E1F3F1; --tone-teal-fg: #136A62;
    --tone-gray-bg: #EEF1F4; --tone-gray-fg: #4A5868;
    --label-blue: #6D8BF0; --label-green: #5DB85E; --label-teal: #2FB392; --label-pink: #D867B9; --label-orange: #F07F3C; --label-purple: #9B7BE8; --label-gray: #7B8794;
    --presence: #2FB392;

    /* Phase C geometry and layout */
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --shadow-card: 0 1px 2px rgba(19, 35, 58, .04), 0 6px 20px rgba(19, 35, 58, .045);
    --shadow-float: 0 12px 32px rgba(19, 35, 58, .12), 0 2px 8px rgba(19, 35, 58, .06);
    --text-hero: 700 40px/52px var(--font-sans);
    --text-section: 700 18px/26px var(--font-sans);
    --text-card-title: 650 16px/24px var(--font-sans);
    --content-max: 1440px;
    --page-gutter: 24px;
    --sidebar-width: 316px;
    --header-height: 72px;
    --control-xl: 52px;
    --avatar-xs: 20px; --avatar-sm: 28px; --avatar-md: 36px; --avatar-lg: 48px; --avatar-xl: 72px;
    /* Text placed on the dark brand illustrations (forest, mountains) and how illustrations sit in each theme. */
    --on-media: #FFFFFF;
    --on-media-muted: rgba(255, 255, 255, .86);
    --media-button: #FFFFFF;
    --on-media-button: #13233A;
    --art-filter: none;
    --hero-text-veil: linear-gradient(90deg, rgba(238, 245, 246, .92) 0%, rgba(238, 245, 246, .78) 42%, rgba(238, 245, 246, 0) 66%);
  }

  :root[data-theme="dark"] {
    color-scheme: dark;
    --bg-primary: #0A1620;
    --bg-secondary: #0D1A25;
    --surface: #101F2B;
    --surface-hover: #162836;
    --surface-raised: #1A2D3B;
    --text-primary: #E6EEF1;
    --text-secondary: #B3C2CA;
    --text-muted: #8C9FAA;
    --border-subtle: #223441;
    --border-default: #34495A;
    --border-strong: #5B7080;
    --accent: #46C2A5;
    --accent-hover: #63CFB5;
    --on-accent: #05231E;
    --accent-subtle: #123A33;
    --success: #4FC08A;
    --success-subtle: #12302A;
    --warning: #E0B04A;
    --warning-subtle: #33290F;
    --danger: #FF8C9C;
    --danger-hover: #FFA3B0;
    --danger-subtle: #3A1C24;
    --on-danger: #05231E;
    --info: #72A9E6;
    --info-subtle: #172A40;
    --focus-ring: #63CFB5;
    --overlay: rgba(0, 0, 0, .6);
    --header-surface: rgba(10, 22, 32, .96);
    --hero-veil: rgba(10, 22, 32, .91);
    --skeleton-base: #182A37;
    --skeleton-shine: #213646;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-2: 0 8px 24px rgba(0, 0, 0, .35);
    --shadow-3: 0 24px 56px rgba(0, 0, 0, .5);
    --brand-ink: #E6EEF1;
    --brand-dot: #46C2A5;
    --accent-strong-start: #46C2A5;
    --accent-strong-end: #34A98E;
    --surface-mint: #11302C;
    --surface-mint-strong: #164038;
    --surface-muted: #0E1C27;
    --hero-sky: #10262E;
    --hero-sky-end: #0C1B24;
    --tone-green-bg: #123126; --tone-green-fg: #7ED9AE;
    --tone-blue-bg: #15283F; --tone-blue-fg: #8DB6F0;
    --tone-purple-bg: #231D3D; --tone-purple-fg: #B8A6F2;
    --tone-pink-bg: #36192A; --tone-pink-fg: #F0A1C3;
    --tone-red-bg: #3A1B1D; --tone-red-fg: #FF9C98;
    --tone-orange-bg: #33230F; --tone-orange-fg: #F4B77A;
    --tone-teal-bg: #10302D; --tone-teal-fg: #74D3C3;
    --tone-gray-bg: #1B2A36; --tone-gray-fg: #B3C2CA;
    --shadow-card: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow-float: 0 12px 32px rgba(0, 0, 0, .45);
    --media-button: #E6EEF1;
    --on-media-button: #0A1620;
    --art-filter: brightness(.38) saturate(.8) contrast(1.05);
    --hero-text-veil: linear-gradient(90deg, rgba(10, 22, 32, .9) 0%, rgba(10, 22, 32, .72) 45%, rgba(10, 22, 32, .2) 75%);
  }

  /*
    Compatibility aliases for pre-Phase-A token names. Existing CSS keeps working;
    later phases migrate usages and remove these. The legacy name --surface is NOT
    aliased: it is now the semantic card surface, and old "subtle background" usages
    were moved to --bg-secondary.
  */
  :root {
    --ink: var(--text-primary);
    --muted: var(--text-muted);
    --blue: var(--accent);
    --brand: var(--accent);
    --on-brand: var(--on-accent);
    --line: var(--border-subtle);
    --white: var(--bg-primary);
    --card-bg: var(--surface);
    --header-bg: var(--header-surface);
    --tag-bg: var(--accent-subtle);
    --tag-ink: var(--accent);
    --caption-bg: var(--bg-secondary);
    --hero-fade: var(--hero-veil);
  }
}

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  button, input, select, textarea { font: inherit; }
}

/* Base: element defaults only. Legacy page rules sit above this layer and still win. */
@layer base {
  body {
    margin: 0;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-sans);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
  }
  h1, h2, h3 { color: var(--text-primary); }
  a { color: inherit; }
  code, kbd, pre, samp { font-family: var(--font-mono); }
  input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); }
  ::selection { background: var(--accent-subtle); color: var(--text-primary); }
  table { font-variant-numeric: tabular-nums; }
}
