/*
 * This is a manifest file that'll be compiled into application.css.
 *
 * With Propshaft, assets are served efficiently without preprocessing steps. You can still include
 * application-wide styles in this file, but keep in mind that CSS precedence will follow the standard
 * cascading order, meaning styles declared later in the document or manifest will override earlier ones,
 * depending on specificity.
 *
 * Consider organizing styles into separate files for maintainability.
 */

/* 한국어 단어 중간 줄바꿈 방지 — 의미 단위로 자연스럽게 끊김 */
html:lang(ko), html[lang="ko"], html {
  word-break: keep-all;
  overflow-wrap: break-word;
}

:root {
  --theme-accent-soft: color-mix(in srgb, var(--color-primary) 12%, white);
  --theme-accent-border: color-mix(in srgb, var(--color-primary) 24%, white);
  --theme-accent-strong: color-mix(in srgb, var(--color-primary) 78%, black);
  --theme-divider: color-mix(in srgb, var(--border-card) 78%, white);
}

.theme-shell {
  width: 100%;
  max-width: 1600px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

.theme-topbar {
  border-bottom: 1px solid var(--theme-divider);
  background: color-mix(in srgb, var(--surface-card) 94%, transparent);
  backdrop-filter: blur(18px);
}

.theme-panel {
  border: 1px solid var(--border-card);
  background: var(--surface-card);
  box-shadow: var(--shadow-card);
}

.theme-panel-soft {
  border: 1px solid var(--theme-divider);
  background: var(--surface-muted);
}

/* ================================
   iOS 26 GLASS UTILITIES (P0 — 시안 web-ios26-renewal.html 미러)
   .glass-panel  = 카드/드로어 surface (iOS ebGlassRegular, blur 40)
   .glass-chrome = 탭바/상단바 크롬 (iOS ebGlassChrome, blur 80)
   ================================ */
.glass-panel {
  background: var(--surface-glass);
  -webkit-backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  backdrop-filter: blur(var(--glass-blur)) saturate(1.3);
  border: 1px solid var(--border-glass);
  box-shadow: var(--shadow-glass);
}

.glass-chrome {
  background: var(--surface-glass-chrome);
  -webkit-backdrop-filter: blur(var(--glass-blur-bg)) saturate(1.6);
  backdrop-filter: blur(var(--glass-blur-bg)) saturate(1.6);
  border-color: var(--border-glass);
}

/* backdrop-filter 미지원 브라우저: 불투명 카드 surface 로 승격해 가독성 보존 */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  .glass-panel,
  .glass-chrome {
    background: var(--surface-card);
  }
}

.theme-accent-panel {
  border: 1px solid var(--theme-accent-border);
  background: linear-gradient(180deg, var(--theme-accent-soft) 0%, var(--surface-card) 100%);
}

.theme-status-panel-queued {
  border: 1px solid color-mix(in srgb, var(--color-status-scheduled) 18%, var(--border-card));
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--color-status-scheduled) 7%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--color-status-scheduled-bg) 70%, var(--surface-card)) 0%, var(--surface-card) 100%);
}

.theme-status-panel-in-progress {
  border: 1px solid color-mix(in srgb, var(--color-status-in-progress) 22%, var(--border-card));
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--color-status-in-progress) 12%, transparent), transparent 52%),
    linear-gradient(180deg, color-mix(in srgb, var(--color-status-in-progress-bg) 78%, var(--surface-card)) 0%, var(--surface-card) 100%);
}

.theme-status-panel-completed {
  border: 1px solid color-mix(in srgb, var(--color-status-completed) 20%, var(--border-card));
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--color-status-completed) 10%, transparent), transparent 54%),
    linear-gradient(180deg, color-mix(in srgb, var(--color-status-completed-bg) 72%, var(--surface-card)) 0%, var(--surface-card) 100%);
}

.theme-heading {
  color: var(--text-heading);
}

.theme-copy {
  color: var(--text-body);
}

.theme-copy-muted {
  color: var(--text-muted);
}

.theme-copy-pretty {
  word-break: keep-all;
  overflow-wrap: anywhere;
  line-break: loose;
  text-wrap: pretty;
}

.theme-eyebrow {
  color: var(--theme-accent-text);
}

.theme-nav-link {
  color: var(--text-body);
  transition: color var(--transition-fast), background-color var(--transition-fast);
}

.theme-nav-link:hover {
  color: var(--text-heading);
}

.theme-nav-link-active {
  color: var(--theme-accent-text);
}

.theme-button-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding-inline: 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--theme-accent-border);
  background: var(--theme-accent-soft);
  color: var(--theme-accent-strong);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.theme-button-primary:hover {
  background: color-mix(in srgb, var(--color-primary) 18%, white);
}

.theme-button-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding-inline: 1.25rem;
  border-radius: 0.75rem;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid var(--border-card);
  background: var(--surface-card);
  color: var(--text-body);
  transition: background-color var(--transition-fast), border-color var(--transition-fast), color var(--transition-fast);
}

.theme-button-secondary:hover {
  background: var(--surface-muted);
  color: var(--text-heading);
}

.theme-input {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border-card);
  background: var(--surface-card);
  color: var(--text-heading);
  font: inherit;
  min-height: 2.75rem;
  line-height: 1.5;
  padding-block: 0;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.theme-input:focus {
  outline: none;
  border-color: var(--theme-accent-outline);
  box-shadow: var(--shadow-focus);
}

.theme-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

.theme-input:disabled {
  color: var(--text-muted);
  background: var(--surface-muted);
}

.theme-select {
  background-color: var(--surface-card);
  color: var(--text-heading);
  background-image: none;
}

.theme-select option {
  background: var(--surface-card);
  color: var(--text-heading);
}

.theme-alert-error {
  border: 1px solid color-mix(in srgb, var(--color-error) 24%, white);
  background: var(--color-error-bg);
  color: color-mix(in srgb, var(--color-error) 78%, black);
}

.theme-stat-card {
  border: 1px solid var(--theme-divider);
  background: var(--surface-muted);
}

.tournament-stat-card {
  border-color: color-mix(in srgb, var(--theme-accent-border) 45%, white);
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--color-primary) 8%, transparent), transparent 55%),
    linear-gradient(180deg, color-mix(in srgb, var(--theme-accent-soft) 28%, var(--surface-card)) 0%, var(--surface-card) 100%);
  box-shadow: 0 1px 2px rgba(26, 21, 35, 0.03);
}

.tournament-stat-card:hover {
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--color-primary) 11%, transparent), transparent 58%),
    linear-gradient(180deg, color-mix(in srgb, var(--theme-accent-soft) 36%, var(--surface-card)) 0%, var(--surface-card) 100%);
}

.theme-marketing-hero {
  background:
    radial-gradient(circle at top left, color-mix(in srgb, var(--color-primary) 16%, transparent), transparent 32%),
    linear-gradient(180deg, color-mix(in srgb, var(--color-primary) 4%, white) 0%, var(--surface-card) 48%, color-mix(in srgb, var(--color-primary) 7%, white) 100%);
}

.theme-display {
  font-family: var(--font-headline-en);
}

.no-scrollbar {
  scrollbar-width: none;
}
.no-scrollbar::-webkit-scrollbar {
  display: none;
}

/* ── Dashboard card collapse/expand ── */
.card-collapsible {
  display: grid;
  grid-template-rows: 1fr;
  transition: grid-template-rows 0.25s ease;
}
.card-collapsible.collapsed {
  grid-template-rows: 0fr;
}
.card-collapsible > * {
  overflow: hidden;
  min-height: 0;
}

/* ── Dashboard DnD states ── */
.dnd-ghost {
  opacity: 0.35;
  border-radius: 1rem;
  background: #e2e8f0;
}
.dnd-chosen {
  box-shadow: 0 20px 40px -8px rgba(0,0,0,0.18);
}

@media (min-width: 640px) {
  .theme-shell {
    padding-inline: 1.5rem;
  }
}

@media (min-width: 1024px) {
  .theme-shell {
    padding-inline: 2rem;
  }
}

/* ================================
   DARK MODE
   Must load after tailwind.css to override :root variables
   ================================ */

/*
 * Dark palette unified to the iOS purple-tinted dark family (T1, 2026-06).
 * SOT: ios EasyBracketShared/Sources/DesignSystem/Color+Dark.swift (DarkHex).
 * Was a slate/translucent-white mix (#020617 / rgba-white / #0f172a / #1e293b);
 * now mirrors the same brand-aligned purple-dark surfaces/borders/text as
 * Android Color.kt Dark*. surface-scoreboard stays #0f172a (always-dark, not here).
 */
.dark {
  /* undefined-ref 수리(2026-08-14): 다크는 라이트 대비 한 단계 밝게 —
     amber-900/950→amber-800/900. */
  /* 🔴 `--color-primary-950` 재정의는 걷어냈다(2026-08-14 시안 확정).
     그것은 뷰가 `dark:bg-[color:var(--color-primary-950)]` 로 틴트 면을 손수 박던
     시절의 보정이었다 — 950 원값(#022c22)이 그 자리에 너무 어두웠기 때문. 이제
     틴트는 `--theme-accent-tint` 가 든다. 원시 스케일을 다크에서 재정의하면
     tokens.css:284 의 "원시 스케일은 모드 무관 재료" 선언과 어긋나고, 950 을
     900 값으로 덮는 순간 tint(950)·tint-strong(900)·line-subtle(900) 이 전부
     한 색으로 붙는다. */
  --color-warning-900: #92400e;
  --color-warning-950: #78350f;
  /* 시맨틱 액센트 레이어(2026-08-14) — 원시 스케일(--color-primary-*)은 그대로 두고
     시맨틱 토큰만 한 단계 밝은 스텝으로 리맵. tokens.css :root 정의와 짝. */
  /* 🔴 채움은 다크에서 **밝은 면 + 어두운 글자**다 (2026-08-14, 시안 raw-ref-221 확정).
     500 위 흰 글자는 2.54:1 로 무너졌다. 400 + text-inverse 는 9.10:1.
     §1.12-1 의 brand exposed swatch(다크 400)와 같은 값이다. */
  --theme-accent-solid: var(--color-primary-400);
  --theme-accent-solid-hover: var(--color-primary-300);
  --theme-accent-on-solid: var(--text-inverse);
  --theme-accent-text: var(--color-primary-500);
  /* outline(선 롤)만 라이트와 같은 500 을 유지한다 — 시안 비교 후 사용자 확정
     (2026-08-14). 선은 면·글자보다 시각 비중이 커서 한 단계 밝히면 과하게
     도드라진다는 판단. 토큰을 거치는 구조는 그대로라, 나중에 400 으로 바꾸려면
     이 한 줄만 고치면 된다. */
  --theme-accent-outline: var(--color-primary-500);
  /* 나머지 6종 — 시안 `.mockups/dark-step-6` 로 사용자 확정 (2026-08-14, A안 + 전경 400).
     결정 근거·대비 실측은 `.planning/dark-step-6-decision.md`, 정본 반영은
     design_guide/native_design_tokens.md §1.12 "Semantic accent (web)" 표.

     전경은 400 이다. §1.12-1 의 "한 단계 밝게" 를 그대로 적용하면 700→600 인데
     600 은 카드 위 4.11:1 로 §1.12-5(≥4.5:1)를 못 넘긴다. 두 조항이 부딪히고
     AA 가 이긴다. 400 은 카드 8.06 · tint(950) 7.88 · tint-strong(900) 5.06 으로
     세 바탕 모두 통과한다. */
  --theme-accent-text-strong: var(--color-primary-400);
  --theme-accent-tint: var(--color-primary-950);
  --theme-accent-tint-strong: var(--color-primary-900);
  /* 🔴 line-subtle 과 tint-strong 은 다크에서 둘 다 900 이다 — 값은 같지만 토큰은
     분리해 둔다(tokens.css 의 "역할별로 분리" 주석: 용도가 다르면 훗날 다른 스텝을
     가리킬 수 있어야 한다). 한쪽만 옮길 때 이 줄만 고치면 된다. */
  --theme-accent-line-subtle: var(--color-primary-900);
  --theme-accent-line: var(--color-primary-800);
  --theme-accent-line-strong: var(--color-primary-700);
  /* §1.8 surfaces */
  --surface-body: #1d1a28;
  --surface-card: #262231;
  --surface-muted: #211e2c;
  --surface-elevated: #262231;
  --surface-sidebar: #262231;
  /* §1.9 borders */
  --border-default: #413d4c;
  --border-subtle: #262231;
  --border-strong: #55505f;
  --border-card: #353140;
  --border-card-light: #262231;
  --shadow-card: 0 4px 20px rgba(0,0,0,0.3);
  --shadow-card-lg: 0 8px 40px rgba(0,0,0,0.4);
  --shadow-slot: 0 2px 8px rgba(0,0,0,0.3);
  /* §1.10 text */
  --text-primary: #e6e3eb;
  --text-secondary: #a9a4af;
  --text-tertiary: #8e8a95;
  --text-inverse: #1c1917;
  --text-heading: #d6d3da;
  --text-body: #c7c2d0;
  --text-muted: #807b86;
  /* iOS 26 glass — 다크 틴트는 위 보라끼 다크 서피스(SOT)를 color-mix 로 추종.
     (iOS Material+Glass.swift 는 slate 0F172A/1E293B 지만, 웹 다크 팔레트는 T1 에서
     보라 틴트로 통일됐고 Grand Slam 테마도 surface 변수를 리맵하므로 하드코딩 대신
     변수 기반이 테마 톤을 보존한다 — codex P2.) */
  --surface-glass: color-mix(in srgb, var(--surface-card) 62%, transparent);
  --surface-glass-chrome: color-mix(in srgb, var(--surface-body) 65%, transparent);
  --border-glass: color-mix(in srgb, var(--border-strong) 45%, transparent);
  --shadow-glass: 0 8px 32px rgba(0, 0, 0, .45), 0 1px 2px rgba(0, 0, 0, .3);
}

/* ================================
   GRAND SLAM THEME SYSTEM
   data-app-theme on <html> remaps Tailwind's emerald-* utilities.
   MUST load after tailwind.css — same specificity as :root,
   so source order determines winner.
   ================================ */

/* Wimbledon: Purple + Green */
[data-app-theme="wimbledon"] {
  --color-emerald-50: #f5f0ff;
  --color-emerald-100: #ede0ff;
  --color-emerald-200: #d4b8ff;
  --color-emerald-300: #b58af5;
  --color-emerald-400: #9b5de5;
  --color-emerald-500: #7B2082;
  --color-emerald-600: #6a1a73;
  --color-emerald-700: #522398;
  --color-emerald-800: #3f0f72;
  --color-emerald-900: #2c0852;
  --color-primary: #522398;
  --color-primary-500: #7B2082;
  --color-primary-600: #6a1a73;
  --color-primary-700: #522398;
  --color-primary-800: #3f0f72;
  --color-accent: #00653A;
  --shadow-focus: 0 0 0 3px rgba(82, 35, 152, 0.2);
}

/* Roland Garros: Clay Orange + Forest Green */
[data-app-theme="roland_garros"] {
  --color-emerald-50: #fff4ec;
  --color-emerald-100: #ffe4cc;
  --color-emerald-200: #ffbd99;
  --color-emerald-300: #ff9466;
  --color-emerald-400: #e8722e;
  --color-emerald-500: #C95917;
  --color-emerald-600: #b04a0d;
  --color-emerald-700: #963d08;
  --color-emerald-800: #7a2f04;
  --color-emerald-900: #5a2002;
  --color-primary: #C95917;
  --color-primary-500: #C95917;
  --color-primary-600: #b04a0d;
  --color-primary-700: #963d08;
  --color-primary-800: #7a2f04;
  --color-accent: #02503B;
  --shadow-focus: 0 0 0 3px rgba(201, 89, 23, 0.2);
}

/* US Open: Navy Blue + Gold */
[data-app-theme="us_open"] {
  --color-emerald-50: #eef3ff;
  --color-emerald-100: #d4e2ff;
  --color-emerald-200: #a3c1ff;
  --color-emerald-300: #6899ff;
  --color-emerald-400: #3370f0;
  --color-emerald-500: #003DA5;
  --color-emerald-600: #002f8a;
  --color-emerald-700: #002370;
  --color-emerald-800: #001857;
  --color-emerald-900: #000e38;
  --color-primary: #003DA5;
  --color-primary-500: #003DA5;
  --color-primary-600: #002f8a;
  --color-primary-700: #002370;
  --color-primary-800: #001857;
  --color-accent: #FFB300;
  --shadow-focus: 0 0 0 3px rgba(0, 61, 165, 0.2);
}

/* Australian Open: Sky Blue + Lime */
[data-app-theme="australian_open"] {
  --color-emerald-50: #e0f5ff;
  --color-emerald-100: #b8e8ff;
  --color-emerald-200: #7fd4ff;
  --color-emerald-300: #3fbbff;
  --color-emerald-400: #0099e0;
  --color-emerald-500: #0085CA;
  --color-emerald-600: #006eaa;
  --color-emerald-700: #005a8c;
  --color-emerald-800: #004470;
  --color-emerald-900: #002d50;
  --color-primary: #0085CA;
  --color-primary-500: #0085CA;
  --color-primary-600: #006eaa;
  --color-primary-700: #005a8c;
  --color-primary-800: #004470;
  --color-accent: #84BD00;
  --shadow-focus: 0 0 0 3px rgba(0, 133, 202, 0.2);
}

/* AI Placement preview highlight */
.ai-preview-assigned {
  border-color: rgb(99 102 241) !important;
  border-width: 2px !important;
  background-color: rgb(237 233 254) !important;
}
