/* Cardnic start page and settings window. Stub look: plain and angular, the real look comes with M2.
   Palette from the logo: ink and paper as the base, "Glut" orange as the single accent (focus ring and the
   corner facet that repeats the faceted logo). Light and dark follow the system. */

:root {
  --paper: #f4efe6;
  --surface: #fbf8f2;
  --ink: #232a36;
  --muted: #4d5563;
  --line: #232a36;
  --accent: #b83a14;
  --backdrop: rgb(35 42 54 / 0.6);
  --font: 'Barlow', system-ui, sans-serif;
  --font-head: 'Barlow Semi Condensed', 'Barlow', system-ui, sans-serif;
  --radius: 3px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #171c24;
    --surface: #1f2631;
    --ink: #f4efe6;
    --muted: #b9b4aa;
    --line: #f4efe6;
    --accent: #f27a52;
    --backdrop: rgb(0 0 0 / 0.65);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--paper);
  color: var(--ink);
  font: 400 1.0625rem/1.45 var(--font);
}

:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

/* ---------- page ---------- */

.page {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100dvh;
  padding: max(2.5rem, env(safe-area-inset-top)) 1rem max(4rem, env(safe-area-inset-bottom));
}

.brand { margin: 0 0 1.5rem; }
.logo { display: block; width: min(17rem, 72vw); height: auto; }
.logo-on-dark { display: none; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo-on-light { display: none; }
  :root:not([data-theme="light"]) .logo-on-dark { display: block; }
}

main { width: 100%; max-width: 26rem; }

.tagline {
  margin: 0 0 2rem;
  text-align: center;
  font: 500 1.25rem/1.3 var(--font-head);
  color: var(--ink);
}

.menu { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.875rem; }

/* ---------- tiles (menu buttons) ---------- */

.tile {
  position: relative;
  display: block;
  width: 100%;
  min-height: 4.25rem;
  padding: 0.75rem 3.5rem 0.75rem 1.125rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.tile-label { display: block; font: 700 1.375rem/1.2 var(--font-head); }
.tile-line { display: block; color: var(--muted); font-size: 1rem; }

/* The corner facet: a cut triangle in the accent colour, only on the live tile. */
.tile-live::after {
  content: '';
  position: absolute;
  top: -2px;
  right: -2px;
  width: 2.25rem;
  height: 2.25rem;
  background: linear-gradient(225deg, var(--accent) 50%, transparent 50%);
  border-top-right-radius: var(--radius);
}

.tile-live:hover { background: var(--ink); color: var(--paper); }
.tile-live:hover .tile-line { color: var(--paper); }
.tile-live:active { transform: translateY(1px); }

.tile:disabled { border-style: dashed; cursor: not-allowed; }

noscript p { margin: 1rem 0 0; text-align: center; }

/* ---------- version corner ---------- */

.corner {
  position: absolute; left: 1rem; right: 1rem; bottom: max(1rem, env(safe-area-inset-bottom));
  display: flex; justify-content: space-between; align-items: baseline; gap: 1rem;
}
.version { color: var(--muted); font-size: 0.9375rem; }
.legal { display: flex; gap: 1rem; }
.legal a { color: var(--muted); font-size: 0.9375rem; text-underline-offset: 0.2em; }
.legal a:hover { color: var(--ink); }

/* ---------- settings window ---------- */

.settings {
  width: min(30rem, calc(100vw - 1.5rem));
  max-height: min(42rem, calc(100dvh - 1.5rem));
  margin: auto;
  padding: 0 1.125rem 1.25rem;
  overflow-y: auto;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
}
.settings::backdrop { background: var(--backdrop); }

.dlg-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  background: var(--paper);
  border-bottom: 2px solid var(--line);
}
.dlg-head h2 { margin: 0; font: 700 1.5rem/1.2 var(--font-head); }

.dlg-close,
.info {
  min-width: 2.75rem;
  min-height: 2.75rem;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  font: 600 1rem/1 var(--font);
  cursor: pointer;
}
.dlg-close { padding: 0 1rem; }
.dlg-close:hover, .info:hover { background: var(--ink); color: var(--paper); }
.info { font-style: italic; font-family: var(--font-head); font-weight: 700; }
.info[aria-expanded="true"] { background: var(--ink); color: var(--paper); }

.notice { margin: 1rem 0 0; padding: 0.625rem 0.75rem; border: 2px dashed var(--line); border-radius: var(--radius); }

.row { padding: 1rem 0; border-bottom: 1px solid color-mix(in srgb, var(--ink) 30%, transparent); }
.row:last-child { border-bottom: 0; padding-bottom: 0; }
.row-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.row-head h3 { margin: 0; font: 700 1.25rem/1.2 var(--font-head); }
.row-line { margin: 0 0 0.625rem; color: var(--muted); }
.row-more { margin: 0 0 0.75rem; padding: 0.5rem 0.75rem; border: 1px solid var(--line); background: var(--surface); }
.row-more[hidden] { display: none; }

/* segmented radio group */
.seg { display: flex; }
.seg-option { position: relative; flex: 1 1 0; }
.seg-option input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg-option span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0 0.5rem;
  border: 2px solid var(--line);
  margin-left: -2px;
  font-weight: 600;
  text-align: center;
}
.seg-option:first-child span { margin-left: 0; border-radius: var(--radius) 0 0 var(--radius); }
.seg-option:last-child span { border-radius: 0 var(--radius) var(--radius) 0; }
.seg-option input:checked + span { background: var(--ink); color: var(--paper); }
.seg-option input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; position: relative; z-index: 1; }

.check { display: flex; align-items: center; gap: 0.75rem; min-height: 2.75rem; font-weight: 600; }
.check input { width: 1.5rem; height: 1.5rem; margin: 0; accent-color: var(--ink); }

.range { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem; min-height: 2.75rem; }
.range input { width: 100%; min-height: 2.75rem; margin: 0; accent-color: var(--ink); }
.range input:disabled { opacity: 0.5; }
.range output { min-width: 3.25rem; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- calm motion ---------- */

.tile, .dlg-close, .info { transition: background-color 0.12s, color 0.12s; }
:root[data-motion="full"] .settings[open] { animation: rise 0.18s ease-out; }
@keyframes rise { from { opacity: 0; transform: translateY(0.75rem); } to { opacity: 1; transform: none; } }

:root[data-motion="reduce"] *,
:root[data-motion="reduce"] *::before,
:root[data-motion="reduce"] *::after { animation: none !important; transition: none !important; }

@media (min-width: 40rem) {
  .page { padding-top: 4rem; }
  .logo { width: 20rem; }
}
