/* Mondopie — single stylesheet, no build step. */

@layer reset, tokens, base, components;

@layer reset {
  *, *::before, *::after { box-sizing: border-box; }
  * { margin: 0; }
  input, button { font: inherit; }
  img, svg { display: block; max-width: 100%; }
}

@layer tokens {
  :root {
    --bg: #faf7f2;
    --surface: #ffffff;
    --text: #1c1917;
    --text-muted: #57534e;
    --brand: #c2410c;
    --brand-strong: #9a3412;
    --brand-contrast: #ffffff;
    --border: #e7e5e4;
    --danger: #b91c1c;
    --danger-bg: #fef2f2;
    --ok: #15803d;
    --focus: #2563eb;
    --radius: 10px;
    --shadow: 0 1px 3px rgb(0 0 0 / 0.08), 0 4px 16px rgb(0 0 0 / 0.06);
  }
  @media (prefers-color-scheme: dark) {
    :root {
      --bg: #17130f;
      --surface: #221c17;
      --text: #f5f0eb;
      --text-muted: #b8aca2;
      --brand: #f97316;
      --brand-strong: #fb923c;
      --brand-contrast: #1c1006;
      --border: #3a322b;
      --danger: #f87171;
      --danger-bg: #35191a;
      --ok: #4ade80;
      --focus: #60a5fa;
      --shadow: 0 1px 3px rgb(0 0 0 / 0.4);
    }
  }
}

@layer base {
  html { color-scheme: light dark; }
  body {
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    line-height: 1.5;
    min-height: 100dvh;
  }
  h1, h2, h3 { line-height: 1.2; text-wrap: balance; }
  a { color: var(--brand); }
  :focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
  @media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
  }
}

@layer components {
  .page-center {
    min-height: 100dvh;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    text-align: center;
  }
  .brand-mark { display: flex; align-items: center; gap: 0.6rem; }
  .brand-mark img { inline-size: 2rem; }
  .brand-mark .name { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.02em; }
  .tagline { color: var(--text-muted); max-inline-size: 32ch; }

  .card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    inline-size: min(24rem, 100%);
    text-align: start;
  }
  .card h2 { font-size: 1.1rem; margin-block-end: 1rem; }

  .field { display: grid; gap: 0.3rem; margin-block-end: 0.9rem; }
  .field label { font-size: 0.875rem; font-weight: 600; }
  .field input {
    padding: 0.55rem 0.7rem;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg);
    color: var(--text);
    inline-size: 100%;
  }
  .field .hint { font-size: 0.8rem; color: var(--text-muted); }

  .button {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 1rem;
    border-radius: 6px;
    border: 1px solid transparent;
    background: var(--brand);
    color: var(--brand-contrast);
    font-weight: 600;
    cursor: pointer;
    inline-size: 100%;
  }
  .button:hover { background: var(--brand-strong); }
  .button[disabled] { opacity: 0.6; cursor: wait; }
  .button.secondary {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
    inline-size: auto;
  }
  .button.secondary:hover { background: var(--bg); }

  .form-links { display: flex; justify-content: center; gap: 1rem; margin-block-start: 1rem; font-size: 0.875rem; }
  .link-button {
    background: none; border: none; padding: 0;
    color: var(--brand); cursor: pointer; text-decoration: underline; font-size: inherit;
  }

  .form-error {
    color: var(--danger);
    background: var(--danger-bg);
    border-radius: 6px;
    padding: 0.6rem 0.8rem;
    font-size: 0.875rem;
    margin-block-end: 0.9rem;
  }
  .form-error:empty { display: none; padding: 0; margin: 0; }
  .form-notice { color: var(--ok); font-size: 0.875rem; margin-block-end: 0.9rem; }

  /* Authenticated shell */
  .shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
  .shell > header {
    display: flex; align-items: center; gap: 1.25rem;
    padding: 0.75rem clamp(1rem, 4vw, 2rem);
    background: var(--surface);
    border-block-end: 1px solid var(--border);
  }
  .shell > header .brand-mark img { inline-size: 1.5rem; }
  .shell > header .brand-mark .name { font-size: 1.1rem; }
  .shell nav { display: flex; gap: 0.25rem; flex-wrap: wrap; }
  .shell nav a {
    text-decoration: none; color: var(--text-muted);
    padding: 0.35rem 0.7rem; border-radius: 6px; font-size: 0.925rem;
  }
  .shell nav a:hover { color: var(--text); background: var(--bg); }
  .shell nav a[aria-current="page"] { color: var(--brand); font-weight: 600; }
  .shell nav a.admin-link { color: var(--brand); }
  .spacer { flex: 1; }
  .shell main { padding: clamp(1rem, 4vw, 2rem); inline-size: min(52rem, 100%); margin-inline: auto; }
  .shell main h1 { font-size: 1.4rem; margin-block-end: 1rem; }

  .kv { display: grid; grid-template-columns: max-content 1fr; gap: 0.4rem 1.25rem; }
  .kv dt { color: var(--text-muted); font-size: 0.9rem; }
  .kv dd { font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

  .badge {
    display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px;
    font-size: 0.75rem; font-weight: 600;
    background: var(--brand); color: var(--brand-contrast);
  }

  .table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
  table { border-collapse: collapse; inline-size: 100%; font-size: 0.9rem; }
  th, td { text-align: start; padding: 0.6rem 0.9rem; border-block-end: 1px solid var(--border); white-space: nowrap; }
  tbody tr:last-child > * { border-block-end: none; }
  th { color: var(--text-muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; }

  .toolbar { display: flex; align-items: center; gap: 0.75rem; margin-block: 1rem; }
  .muted { color: var(--text-muted); font-size: 0.875rem; }
}
