/* Matcha landing page. Tokens copied from src/web/theme.ts so the site matches
   the server's sign-in pages. Light by default, dark via prefers-color-scheme. */
:root {
  color-scheme: light dark;
  --bg: #f6f4ec;
  --surface: #ffffff;
  --text: #1b1f18;
  --muted: #5d6657;
  --border: #dcd8c9;
  --accent: #55782f;
  --accent-text: #ffffff;
  --danger: #a3341f;
  --code-bg: #1c211a;
  --code-text: #e9efdf;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(27, 31, 24, 0.12);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Page-specific, derived from the tokens above. */
  --hover: rgba(27, 31, 24, 0.06);
  --backdrop: rgba(27, 31, 24, 0.32);
  --logo-shadow: 0 18px 40px rgba(27, 31, 24, 0.22), 0 4px 10px rgba(27, 31, 24, 0.12);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --gutter: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #11140f;
    --surface: #1a1e17;
    --text: #edf1e6;
    --muted: #a3ad9a;
    --border: #2e3529;
    --accent: #9cc267;
    --accent-text: #11140f;
    --danger: #f08a73;
    --code-bg: #0b0d0a;
    --code-text: #e9efdf;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);

    --hover: rgba(237, 241, 230, 0.07);
    --backdrop: rgba(0, 0, 0, 0.6);
    --logo-shadow: 0 18px 40px rgba(0, 0, 0, 0.55), 0 4px 10px rgba(0, 0, 0, 0.35);
  }
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- Logo ---------- */
.stage {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--gutter);
}
.logo { margin: 0; line-height: 0; }
.logo img {
  display: block;
  width: clamp(144px, 38vmin, 256px);
  height: auto;
  aspect-ratio: 1;
  border-radius: 22.3%;
  box-shadow: var(--logo-shadow);
  user-select: none;
  -webkit-user-drag: none;
}

/* ---------- Menu ---------- */
.menu {
  position: fixed;
  top: max(var(--gutter), env(safe-area-inset-top));
  right: max(var(--gutter), env(safe-area-inset-right));
  z-index: 10;
}
.menu-button {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(27, 31, 24, 0.06);
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.menu-button:hover { border-color: var(--muted); }
.menu-button[aria-expanded="true"] { background: var(--bg); border-color: var(--muted); }
.menu-icon { display: block; }

.menu-list {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 184px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transform-origin: top right;
  transition: opacity 140ms var(--ease), transform 140ms var(--ease);
}
@starting-style {
  .menu-list { opacity: 0; transform: translateY(-4px) scale(0.98); }
}
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.menu-item:hover, .menu-item:focus { background: var(--hover); }
.menu-item:focus { outline: none; }
.menu-item:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* ---------- Dialog ---------- */
.sheet {
  width: min(720px, calc(100vw - 2 * var(--gutter)));
  max-height: calc(100dvh - 2 * var(--gutter));
  margin: auto;
  padding: 20px 24px 24px;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) + 4px);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  overflow: auto;
  overscroll-behavior: contain;
}
.sheet[open] {
  transition: opacity 160ms var(--ease), transform 160ms var(--ease);
}
@starting-style {
  .sheet[open] { opacity: 0; transform: translateY(6px); }
}
.sheet::backdrop { background: var(--backdrop); }

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.sheet-title { margin: 0; font-size: 18px; font-weight: 650; line-height: 1.3; }

.icon-button {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  margin-right: -8px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.icon-button:hover { background: var(--hover); color: var(--text); }

.step-label { margin: 16px 0 8px; color: var(--muted); font-size: 15px; }

.code-row {
  display: flex;
  align-items: stretch;
  gap: 8px;
  min-width: 0;
}
.code {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 11px 14px;
  overflow-x: auto;
  border-radius: 10px;
  background: var(--code-bg);
  color: var(--code-text);
  font-family: var(--mono);
  font-size: 13.5px;
  line-height: 1.5;
  white-space: pre;
  scrollbar-width: thin;
}
.code code { font: inherit; }
.code-box {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
}
/* Set by main.js while more of the line is hidden to the right: fade the text
   into the box so it is obvious the box scrolls. */
.code-box::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 36px;
  border-radius: 0 10px 10px 0;
  background: linear-gradient(to right, transparent, var(--code-bg) 80%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 120ms ease;
}
.code-box.has-more::after { opacity: 1; }

.copy-button {
  flex: none;
  display: grid;
  place-items: center;
  padding: 0 14px;
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 550;
  cursor: pointer;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.copy-button:hover { border-color: var(--muted); }
/* Both labels share one grid cell so the button never changes size. */
.copy-button > span { grid-area: 1 / 1; }
.copy-done { visibility: hidden; }
.copy-button.is-copied { border-color: var(--accent); color: var(--accent); }
.copy-button.is-copied .copy-idle { visibility: hidden; }
.copy-button.is-copied .copy-done { visibility: visible; }

@media (max-width: 420px) {
  .sheet { padding: 16px 16px 20px; }
  .code { padding: 10px 12px; font-size: 13px; }
  .copy-button { padding: 0 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}
