/* Visual polish layered over app.css: depth, motion and a finished sign-in screen.
   Only adds or refines; app.css stays the source of layout. Motion respects prefers-reduced-motion. */

:root {
  --shadow-1: 0 1px 2px rgba(0, 0, 0, .28), 0 1px 1px rgba(0, 0, 0, .18);
  --shadow-2: 0 8px 24px -10px rgba(0, 0, 0, .55), 0 2px 6px rgba(0, 0, 0, .25);
  --glow: rgba(226, 165, 74, .10);
  --ease: cubic-bezier(.2, .8, .2, 1);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --shadow-1: 0 1px 2px rgba(31, 28, 20, .06), 0 1px 1px rgba(31, 28, 20, .04);
    --shadow-2: 0 10px 28px -12px rgba(31, 28, 20, .22), 0 2px 6px rgba(31, 28, 20, .06);
    --glow: rgba(148, 96, 15, .08);
  }
}
:root[data-theme="light"] {
  --shadow-1: 0 1px 2px rgba(31, 28, 20, .06), 0 1px 1px rgba(31, 28, 20, .04);
  --shadow-2: 0 10px 28px -12px rgba(31, 28, 20, .22), 0 2px 6px rgba(31, 28, 20, .06);
  --glow: rgba(148, 96, 15, .08);
}

/* ── Surfaces ── */
body {
  background:
    radial-gradient(1100px 520px at 85% -8%, var(--glow), transparent 62%),
    radial-gradient(900px 480px at -10% 110%, var(--glow), transparent 60%),
    var(--bg);
  background-attachment: fixed;
}
.sidenav {
  background: color-mix(in srgb, var(--surface-1) 86%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.card { box-shadow: var(--shadow-1); transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease); }
a.card:hover, .card.clickable:hover, a.game-row:hover {
  box-shadow: var(--shadow-2);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
}
a.card:hover { transform: translateY(-1px); }
.page-head h1 { letter-spacing: -.02em; }

/* ── Navigation ── */
.brand img { border-radius: 9px; box-shadow: var(--shadow-1); transition: transform .3s var(--ease); }
.brand:hover img { transform: rotate(-6deg) scale(1.05); }
.navlinks a { position: relative; transition: background .15s var(--ease), color .15s var(--ease); }
.navlinks a svg { transition: transform .2s var(--ease), color .2s var(--ease); }
.navlinks a:hover svg { transform: translateX(2px); }
.navlinks a.active { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
.navlinks a.active svg { color: var(--accent); }
.navlinks a.active::before {
  content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0;
  background: var(--accent); animation: nav-mark .25s var(--ease);
}
.tabbar a.active svg { color: var(--accent); }
@keyframes nav-mark { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ── Controls ── */
.btn { transition: background .15s var(--ease), border-color .15s var(--ease), box-shadow .15s var(--ease), transform .08s var(--ease), filter .15s; }
.btn:active:not([disabled]) { transform: translateY(1px) scale(.985); }
.btn.primary {
  background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent));
  box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 4px 12px -6px var(--accent);
}
.btn.primary:hover { box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 8px 18px -8px var(--accent); }
.btn:focus-visible, .input:focus-visible, select.input:focus-visible, a:focus-visible {
  outline: 2px solid var(--focus); outline-offset: 2px;
}
.input, select.input { transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s; }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); outline: none; }
.progress i { background: linear-gradient(90deg, var(--accent), color-mix(in srgb, var(--accent) 70%, white)); transition: width .4s var(--ease); }
.notice { box-shadow: var(--shadow-1); }

/* ── Motion ── */
.page-enter { animation: page-in .32s var(--ease) both; }
.page-enter .card, .page-enter .stat { animation: rise .42s var(--ease) both; }
.page-enter .grid > :nth-child(2) { animation-delay: .04s; }
.page-enter .grid > :nth-child(3) { animation-delay: .08s; }
.page-enter .grid > :nth-child(4) { animation-delay: .12s; }
.page-enter .grid > :nth-child(n+5) { animation-delay: .16s; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
#toast { box-shadow: var(--shadow-2); }

/* ── Sign-in, sign-up and account linking ── */
.account-entry { max-width: 980px; margin: 40px auto; display: grid; grid-template-columns: 1.05fr 1fr; gap: 0;
  border: 1px solid var(--line); border-radius: 18px; overflow: hidden; box-shadow: var(--shadow-2); background: var(--surface-1);
  animation: rise .45s var(--ease) both; }
.account-entry > .card { border: 0; border-radius: 0; box-shadow: none; padding: 36px; align-self: center; animation: none; }
.auth-hero { position: relative; padding: 36px; color: #f4f2ec; display: flex; flex-direction: column; justify-content: space-between; gap: 28px;
  background:
    linear-gradient(160deg, rgba(14, 18, 27, .80), rgba(14, 18, 27, .95)),
    conic-gradient(from 90deg at 50% 50%, #557481 25%, #e9e2d0 0 50%, #557481 0 75%, #e9e2d0 0) 0 0 / 56px 56px; }
.auth-hero .brand-mini { color: #fff; }
.auth-hero .brand-mini small { color: rgba(255, 255, 255, .6); }
.auth-hero h2 { margin: 0; font-size: 30px; line-height: 1.15; letter-spacing: -.02em; }
.auth-hero h2 em { font-style: normal; color: #f1c27d; }
.auth-hero ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.auth-hero li { display: grid; grid-template-columns: 36px 1fr; gap: 12px; align-items: start; font-size: 14px; color: rgba(255, 255, 255, .78); }
.auth-hero li b { display: block; color: #fff; font-size: 15px; margin-bottom: 2px; }
.auth-hero li .ic { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  background: rgba(226, 165, 74, .14); color: #f1c27d; border: 1px solid rgba(226, 165, 74, .26); }
.auth-hero li .ic svg { width: 19px; height: 19px; }
.auth-hero .knight { position: absolute; right: -18px; bottom: -40px; font-size: 220px; line-height: 1; color: rgba(255, 255, 255, .05);
  pointer-events: none; animation: drift 9s ease-in-out infinite alternate; }
@keyframes drift { from { transform: translateY(0) rotate(-4deg); } to { transform: translateY(-10px) rotate(2deg); } }
.account-entry h1 { font-size: 24px; letter-spacing: -.02em; }
.btn.social { justify-content: center; gap: 10px; font-weight: 600; background: var(--surface-1); border-color: var(--line); box-shadow: var(--shadow-1); }
.btn.social:hover { background: var(--surface-2); }
.btn.social .logo { width: 18px; height: 18px; flex: none; display: grid; place-items: center; }
.btn.social .logo svg { width: 18px; height: 18px; }
.btn.social .logo.lichess { font-size: 22px; line-height: 1; margin-top: -3px; }
body.auth-screen .shell { grid-template-columns: 1fr; }
body.auth-screen .sidenav, body.auth-screen .tabbar { display: none; }
@media (max-width: 860px) {
  .account-entry { grid-template-columns: 1fr; margin: 16px auto; max-width: 460px; }
  .auth-hero { padding: 22px 24px; gap: 14px; }
  .auth-hero ul, .auth-hero .knight { display: none; }
  .auth-hero h2 { font-size: 21px; }
  .account-entry > .card { padding: 24px; }
}

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

/* ── Phones ── */
@media (max-width: 860px) {
  .tabbar { grid-template-columns: repeat(6, 1fr) !important; box-shadow: 0 -6px 18px -12px rgba(0, 0, 0, .35); }
  .tabbar a, .tabbar .more-tab { position: relative; }
  .tabbar .more-tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 6px 0;
    font: inherit; font-size: 11px; color: var(--text-2); background: none; border: 0; cursor: pointer; }
  .tabbar .more-tab svg { width: 20px; height: 20px; }
  .tabbar .more-tab.active, .tabbar .more-tab[aria-expanded="true"] { color: var(--accent); }
  .tabbar a.active::after, .tabbar .more-tab.active::after { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--accent); animation: nav-mark .25s var(--ease); }

  .more-sheet { position: fixed; inset: 0; z-index: 30; }
  .more-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, .35); animation: page-in .2s var(--ease); }
  .more-panel { position: absolute; left: 10px; right: 10px; bottom: calc(var(--tab-h) + 10px + env(safe-area-inset-bottom));
    display: grid; gap: 2px; padding: 8px; border-radius: 16px; background: var(--surface-1); border: 1px solid var(--line);
    box-shadow: var(--shadow-2); animation: sheet-up .25s var(--ease); }
  .more-panel a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 10px; color: var(--text); font-weight: 500; }
  .more-panel a svg { width: 20px; height: 20px; color: var(--text-2); }
  .more-panel a.active { background: color-mix(in srgb, var(--accent) 14%, var(--surface-2)); }
  .more-panel a.active svg { color: var(--accent); }
  @keyframes sheet-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }

  /* Compact page header so boards and puzzles start higher. */
  .page-head { margin-bottom: 12px; gap: 10px; align-items: center; }
  .page-head h1 { font-size: 20px; }
  .page-head p { font-size: 13px; margin-top: 2px; }
  .page-head .btn { min-height: 34px; padding: 0 11px; font-size: 13px; }

  /* Rating tiles: one swipeable row instead of a cramped grid. */
  .tiles { display: flex !important; overflow-x: auto; scroll-snap-type: x mandatory; gap: 10px !important;
    margin: 0 -16px 16px; padding: 2px 16px 6px; scrollbar-width: none; }
  .tiles::-webkit-scrollbar { display: none; }
  .tiles > .card { flex: 0 0 clamp(132px, 40vw, 180px); scroll-snap-align: start; }
  .tiles .stat .l { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
}
@media (max-width: 860px) and (prefers-reduced-motion: no-preference) {
  .tabbar a:active svg, .tabbar .more-tab:active svg { transform: scale(.9); }
  .tabbar svg { transition: transform .12s var(--ease); }
}

/* ── Coach chat: a thinking indicator that can't be missed ── */
.coach-chat-thinking .loading-state.compact { padding: 4px 0 0; color: var(--text-2); font-size: 13px; }
.coach-chat form .btn .spinner { width: 14px; height: 14px; border-width: 2px; margin-right: 6px; }

/* ── Practice: what to practise ── */
.practice-modes { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 8px; }
.practice-mode { display: inline-flex; align-items: center; gap: 7px; min-height: 34px; padding: 0 12px; border: 1px solid var(--line); border-radius: 99px; background: var(--surface-2); color: var(--text-2); font: 500 13px/1.2 var(--font); cursor: pointer; transition: background .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease); }
.practice-mode:hover { color: var(--text); border-color: var(--text-3); }
.practice-mode:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.practice-mode .num { font-size: 12px; font-weight: 600; color: var(--text-3); }
.practice-mode.none { color: var(--text-3); }
.practice-mode.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.practice-mode.on .num { color: var(--accent-ink); }
.practice-modes-sep { width: 1px; height: 20px; margin: 0 4px; background: var(--line); }
.practice-mode-about { margin: 0 0 14px; font-size: 13px; }
.practice-empty h2 { margin: 0 0 6px; }

/* ── Practice with nothing to solve: message and next step on top, settings right under them ── */
.tactic-trainer.is-empty { grid-template-columns: minmax(0, 1fr); gap: 12px; }
.tactic-trainer.is-empty .tactic-board-column,
.tactic-trainer.is-empty #tactic-actions,
.tactic-trainer.is-empty #tactic-followup { display: none; }
.tactic-trainer.is-empty .tactic-panel { max-height: none; overflow: visible; padding-right: 0; scrollbar-gutter: auto; }
.tactic-trainer.is-empty #scout-status,
.tactic-trainer.is-empty .tactic-options { grid-row: auto; }
.tactic-trainer.is-empty #scout-status p { margin: 0; }
.tactic-trainer.is-empty .tactic-options { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface-1); box-shadow: var(--shadow-1); padding: 14px 16px; }
.tactic-trainer.is-empty .tactic-options > summary { font-weight: 600; cursor: pointer; }
.tactic-trainer.is-empty .tactic-option-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 20px; align-items: start; }
.tactic-trainer.is-empty #scout-config,
.tactic-trainer.is-empty #tactic-pool-note,
.tactic-trainer.is-empty .tactic-method { grid-column: 1 / -1; margin: 0; }
.tactic-trainer.is-empty #scout-config form { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 20px; align-items: end; }
.tactic-trainer.is-empty #scout-config form > button { order: 2; justify-self: start; }
.tactic-trainer.is-empty #scout-config form > p { order: 3; grid-column: 1 / -1; margin: 0; font-size: 13px; }
.tactic-trainer.is-empty #scout-config form > .scout-config-result { order: 4; grid-column: 1 / -1; }
@media (min-width: 901px) {
  .tactic-trainer.is-empty .practice-empty { flex-direction: row; align-items: center; justify-content: space-between; gap: 24px; }
  .tactic-trainer.is-empty .practice-empty p { max-width: 70ch; }
  .tactic-trainer.is-empty .practice-empty-actions { flex: none; max-width: 50%; justify-content: flex-end; }
}

/* ── Game rows: labelled move-quality counts ── */
.gamerow .gcounts { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-top: 3px; font-size: 12px; color: var(--text-2); }
.gamerow .gcount { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.gamerow .gcount .cls { width: 16px; height: 16px; font-size: 9px; }

/* ── Account ── */
.account-hero { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; padding: 20px; }
.account-identity { display: flex; align-items: center; gap: 16px; flex: 1 1 280px; min-width: 0; }
.account-avatar { flex: none; width: 68px; height: 68px; border-radius: 50%; display: grid; place-items: center; font-size: 24px; font-weight: 700; letter-spacing: .01em; color: var(--accent-ink); background: linear-gradient(180deg, color-mix(in srgb, var(--accent) 88%, white), var(--accent)); box-shadow: 0 1px 0 rgba(255, 255, 255, .18) inset, 0 6px 16px -8px var(--accent); }
.account-who { min-width: 0; }
.account-kicker { display: block; font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--text-3); }
.account-who h1 { margin: 2px 0 0; font-size: 24px; line-height: 1.2; letter-spacing: -.02em; overflow-wrap: anywhere; }
.account-who p { margin: 2px 0 0; color: var(--text-2); font-size: 14px; overflow-wrap: anywhere; }
.account-tags { gap: 6px; margin-top: 8px; }
.account-plan-tag { background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.account-section-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 2px 12px; }
.account-section-head h3 { margin: 0; }
.account-section-head .muted { font-size: 13px; }
.account-section { margin-top: 16px; }
.account-meter { display: flex; flex-direction: column; gap: 6px; }
.account-meter-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.account-meter-head .num { color: var(--text-3); font-size: 13px; white-space: nowrap; }
.account-meter-head strong { color: var(--text); font-size: 18px; }
.account-meter-foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px 12px; font-size: 13px; }
.account-meter-foot .muted { flex: 1 1 220px; }
.account-meter-left { font-weight: 600; color: var(--text-2); white-space: nowrap; }
.account-meter .progress.warn i { background: var(--c-mistake); }
.account-meter .progress.full i { background: var(--loss); }
.account-offers { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.account-offer { display: flex; flex-direction: column; gap: 10px; padding: 14px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius-sm); }
.account-offer p, .account-offer h4 { margin: 0; }
.account-offer-price { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px; }
.account-offer-price strong { font-size: 24px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

/* Game rows follow the width of their card, not the screen: in a narrow card the buttons take their own line. */
.card:has(> .gamerow), .card:has(.gamerow) { container-type: inline-size; }
@container (max-width: 760px) {
  .gamerow { grid-template-columns: 34px minmax(0, 1fr); gap: 6px 12px; }
  .gamerow .acts { grid-column: 2; flex-wrap: wrap; }
}
