/* ==========================================================================
   Dermatordle — shared base: tokens, reset, loading, buttons, top bar, drawer.
   Loaded by every page. Game board styles live in game.css; other pages in pages.css.
   ========================================================================== */

:root {
  --bg: #f7f5ef;
  --surface: #ffffff;
  --ink: #1b2116;
  --ink-2: #545c4c;
  --ink-3: #7d8475;
  --line: #e3dfd3;
  --line-strong: #cfc9b8;
  --tile: #efece3;

  --green: #4c7a24;
  --green-deep: #33561a;
  --green-soft: #e7f0da;
  --miss: #7a776c;
  --miss-deep: #57554c;
  --miss-soft: #ecebe6;
  --danger: #b3473a;
  --hint: #f0bd3f;
  --hint-soft: #fdf4d8;
  --slate: #3d4a5c;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow-pop: 0 18px 48px rgba(27, 33, 22, 0.18);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --board-max: 1120px;
}

/* Laptop/desktop: render the whole site at 80% scale (matches the
   browser's 80% zoom). --vh cancels the zoom so viewport-height sizing
   still means the full window. Touch devices and narrow windows stay 1:1. */
:root { --page-zoom: 1; --vh: calc(1vh / var(--page-zoom)); }
@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  :root { --page-zoom: 0.8; }
  html { zoom: 0.8; }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 76px; }
body {
  margin: 0;
  min-height: calc(100 * var(--vh));
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3, h4 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; }
p { margin: 0; }
.hidden { display: none !important; }
[hidden] { display: none !important; }
.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;
}
:focus-visible { outline: 3px solid var(--hint); outline-offset: 2px; }

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 2000;
  padding: 10px 14px; border-radius: var(--radius-sm);
  background: var(--ink); color: #fff; font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: 12px; }

/* ---------- Loading ---------- */
html.app-loading, html.app-loading body { overflow: hidden; }
html.app-loading .app-shell { visibility: hidden; opacity: 0; }
html.app-loading body::before {
  content: ""; position: fixed; inset: 0; z-index: 9998;
  background: var(--bg) url("./assets/turtle-192.png") center calc(50% - 20px) / 72px 72px no-repeat;
}
html.app-loading body::after {
  content: ""; position: fixed; top: calc(50% + 42px); left: 50%; z-index: 9999;
  width: 44px; height: 6px; margin-left: -22px; border-radius: 3px;
  background: linear-gradient(90deg, var(--green) 0 30%, var(--line) 30% 100%);
  background-size: 200% 100%;
  animation: boot-bar 900ms linear infinite;
}
html.app-ready .app-shell { animation: fade-in 200ms ease-out both; }
@keyframes boot-bar { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

html.lightbox-open, body.lightbox-open,
body.navigation-open, body.archive-modal-open { overflow: hidden; }

/* ---------- Buttons ---------- */
.primary-btn,
.secondary-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 22px;
  border-radius: var(--radius);
  font-weight: 800; font-size: 1rem; letter-spacing: -0.005em;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 120ms ease;
}
.primary-btn {
  border: 0; color: #fff; background: var(--ink);
  box-shadow: 0 3px 0 #000;
}
.primary-btn:hover:not(:disabled) { background: #2a3223; }
.primary-btn:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 1px 0 #000; }
.primary-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.secondary-btn {
  border: 2px solid var(--ink); color: var(--ink); background: var(--surface);
  box-shadow: 0 3px 0 var(--ink);
}
.secondary-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--ink); }
.text-btn {
  border: 0; background: none; padding: 6px 2px;
  color: var(--ink); font-weight: 700; text-decoration: underline;
  text-decoration-thickness: 2px; text-underline-offset: 4px; text-decoration-color: var(--hint);
}
.icon-btn {
  display: inline-grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: 10px; background: transparent;
  font-size: 1.5rem; line-height: 1; color: var(--ink);
}
.icon-btn:hover { background: var(--tile); }
.icon-btn:disabled { opacity: 0.3; cursor: default; background: none; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  height: 60px; padding: 0 max(12px, env(safe-area-inset-left));
  background: rgba(247, 245, 239, 0.94);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(1.4) blur(8px);
  backdrop-filter: saturate(1.4) blur(8px);
}
.menu-toggle { justify-self: start; display: grid; align-content: center; gap: 4px; }
.menu-toggle span { display: block; width: 20px; height: 2.5px; border-radius: 2px; background: var(--ink); }
.brand-lockup {
  display: inline-flex; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
}
.topbar-logo { width: 36px; height: 36px; border-radius: 50%; }
.brand-name { font-size: 1.3rem; font-weight: 900; letter-spacing: -0.035em; }
.beta-tag {
  padding: 2px 7px; border-radius: 6px;
  background: var(--ink); color: var(--hint);
  font-size: 0.66rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase;
}
.account-link {
  justify-self: end; display: inline-flex; align-items: center; gap: 8px;
  height: 40px; padding: 0 12px; border-radius: 10px;
  text-decoration: none; font-weight: 700; font-size: 0.92rem;
}
.account-link:hover { background: var(--tile); }
.account-link svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

/* ---------- Drawer ---------- */
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 400;
  background: rgba(20, 24, 16, 0.4);
  animation: fade-in 150ms ease-out;
}
.site-drawer {
  position: absolute; inset: 0 auto 0 0;
  display: flex; flex-direction: column;
  width: min(340px, 88vw); padding: 16px;
  background: var(--surface);
  animation: drawer-in 220ms var(--ease-out);
}
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: none; } }
.drawer-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.drawer-brand { display: flex; align-items: center; gap: 10px; font-size: 1.2rem; font-weight: 900; letter-spacing: -0.03em; }
.drawer-brand img { border-radius: 50%; }
.drawer-navigation { display: grid; gap: 4px; }
.drawer-primary-link {
  display: grid; gap: 2px; text-align: left; text-decoration: none;
  margin-bottom: 10px; padding: 16px;
  border: 0; border-radius: var(--radius);
  background: var(--green); color: #fff;
  box-shadow: 0 3px 0 var(--green-deep);
}
.drawer-primary-link strong { font-size: 1rem; font-weight: 800; }
.drawer-primary-link span { font-size: 0.85rem; font-weight: 500; opacity: 0.9; }
.drawer-link {
  display: flex; flex-direction: column; gap: 1px; text-align: left;
  padding: 12px 14px; border: 0; border-radius: 10px; background: none;
  font-size: 1rem; font-weight: 800; text-decoration: none; color: var(--ink);
}
.drawer-link span { font-size: 0.85rem; font-weight: 500; color: var(--ink-3); }
.drawer-link:hover { background: var(--tile); }
.drawer-link[aria-current="page"] { background: var(--hint-soft); box-shadow: inset 3px 0 0 var(--hint); }
.account-link[aria-current="page"] { background: var(--tile); }
.drawer-legal-link { display: inline-block; margin-top: 6px; color: var(--ink-2); font-weight: 700; }
.drawer-footer { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 0.85rem; }
.reset-progress-btn {
  margin-top: 10px; padding: 8px 0; border: 0; background: none;
  color: var(--danger); font-size: 0.85rem; font-weight: 700;
}


/* ---------- Small screens (shared chrome) ---------- */
@media (max-width: 560px) {
  .topbar { height: 56px; }
  .brand-name { font-size: 1.15rem; }
  .topbar-logo { width: 32px; height: 32px; }
  .account-link span { display: none; }
  .account-link { padding: 0 8px; }
}
@media (max-width: 380px) {
  .beta-tag { display: none; }
}
