/* Fraunces and Outfit, SIL Open Font License. See fonts/OFL-*.txt. */
@font-face {
  font-family: Fraunces;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/fraunces.woff2") format("woff2");
}
@font-face {
  font-family: Outfit;
  font-style: normal;
  font-weight: 100 900;
  font-display: swap;
  src: url("./fonts/outfit.woff2") format("woff2");
}

:root {
  color-scheme: light;
  --bg: #efe6d4;
  --glow: #f6e2b8;
  --ink: #221c16;
  --muted: #5c5348;
  --line: #e0d3bf;
  --paper: #fffdf8;
  --sunken: #f4ecdf;
  --brass: #8a5a10;
  --brass-btn: #6e470c;
  --brass-ink: #fffaf3;
  --chip: #f3e2b8;
  --chip-ink: #6e470c;
  --leave: #9c2f1e;
  --focus: #6e470c;
  --shadow: 0 16px 40px rgba(70, 46, 12, 0.1);
  --danger: #8f2d22;
  --font: Outfit, "Avenir Next", "Segoe UI", sans-serif;
  --display: Fraunces, "Iowan Old Style", Palatino, Georgia, serif;
  --mono: "iA Writer Mono S", ui-monospace, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #12100e;
    --glow: #3a2a14;
    --ink: #f6efe4;
    --muted: #cbbba6;
    --line: #3a322a;
    --paper: #221c17;
    --sunken: #181410;
    --brass: #e2ae45;
    --brass-btn: #e2ae45;
    --brass-ink: #1c1408;
    --chip: #3a2c14;
    --chip-ink: #f0c56a;
    --leave: #ff8d7a;
    --focus: #e2ae45;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
    --danger: #ffb0a4;
  }
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--ink);
  background:
    radial-gradient(900px 420px at -10% -10%, var(--glow), transparent 55%),
    var(--bg);
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
  display: grid;
  grid-template-columns: minmax(0, 0.86fr) minmax(0, 1.14fr);
  gap: 48px;
  align-items: start;
}

header { position: sticky; top: 28px; min-width: 0; }
main { min-width: 0; display: grid; gap: 16px; align-content: start; }

h1, h2, .code, .leave-host { font-family: var(--display); font-weight: 560; letter-spacing: -0.03em; }

h1 {
  margin: 0;
  font-size: clamp(3.2rem, 7vw, 5.4rem);
  line-height: 0.92;
}

h2 { margin: 0; font-size: 1.35rem; }

.brand { display: flex; gap: 14px; align-items: center; }
.mark { width: 52px; height: 52px; color: var(--ink); flex: none; }

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--brass);
}

.lede { margin: 18px 0 0; font-size: 1.12rem; max-width: 38ch; }
.fine, .hint, .clip-meta, .leave-go { color: var(--muted); }
.hint, .fine, .leave-go { margin: 8px 0 0; font-size: 0.92rem; }
.fine { margin: 14px 0 0; }

.steps {
  margin: 22px 0 0;
  padding: 0;
  list-style: none;
  counter-reset: step;
  display: grid;
  gap: 12px;
  max-width: 42ch;
}
.steps li {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  gap: 10px;
  align-items: start;
}
.steps li::before {
  counter-increment: step;
  content: counter(step);
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--chip);
  color: var(--chip-ink);
  font-family: var(--display);
  font-size: 0.95rem;
}

.card, .leave, .library, .ticket {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
}

.card, .leave, .library { padding: 18px 18px 16px; }

label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 8px; }

input {
  width: 100%;
  min-width: 0;
  min-height: 48px;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--sunken);
  color: var(--ink);
  font-size: 1rem;
}
#share-link { font-family: var(--mono); font-size: 0.82rem; }

.composer-row { display: flex; gap: 8px; align-items: stretch; }
.composer-row input { flex: 1; }

button {
  font: inherit;
  cursor: pointer;
  min-height: 48px;
  border-radius: 999px;
  padding: 0.65rem 1.05rem;
}
button:disabled { cursor: not-allowed; opacity: 0.65; }

.primary {
  background: var(--brass-btn);
  color: var(--brass-ink);
  border: 1px solid transparent;
  font-weight: 600;
}
.primary:hover { filter: brightness(1.08); }

.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}
.ghost:hover { background: var(--sunken); }

.row, .tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }

.error { color: var(--danger); font-weight: 600; margin: 8px 0 0; }

.leave { border-left: 6px solid var(--leave); }
.leave h2 {
  font-family: var(--font);
  font-weight: 600;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1.3;
  margin: 4px 0 10px;
}
.leave-host {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.02;
  overflow-wrap: anywhere;
}
.leave-url, .ticket-dest {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.84rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
  background: var(--sunken);
  border-radius: 12px;
  padding: 10px 12px;
}
.leave-bad { margin: 0 0 8px; font-weight: 600; }

.ticket {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 188px;
  padding: 0;
  overflow: hidden;
}
.ticket-body { padding: 18px 18px 16px; min-width: 0; }
.stub {
  border-left: 1px dashed var(--line);
  padding: 16px;
  display: grid;
  align-content: center;
  background:
    radial-gradient(circle at 0 18px, transparent 8px, var(--paper) 9px);
}

.stamp {
  display: inline-block;
  font-family: var(--display);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  border: 2px solid var(--brass);
  border-radius: 8px;
  padding: 2px 8px;
  transform: rotate(-8deg);
}
.code {
  margin: 10px 0 0;
  font-size: clamp(2.6rem, 6vw, 4rem);
  line-height: 0.95;
}
.ticket-host { margin: 4px 0 10px; font-weight: 600; overflow-wrap: anywhere; }
.ticket-dest { margin-bottom: 12px; }

.qr-hit {
  width: 100%;
  background: #fffaf2;
  color: #1c1612;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 8px;
  display: grid;
  justify-items: center;
  gap: 4px;
}
.qr-hit svg { width: 132px; height: auto; display: block; }
.qr-caption { font-size: 0.78rem; color: #5c5348; }

.library-head { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.library-head h2 { font-family: var(--font); font-weight: 650; letter-spacing: -0.02em; }
.empty { margin: 12px 0 0; color: var(--muted); }
.clip-list { list-style: none; margin: 8px 0 0; padding: 0; }
.clip {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-top: 1px solid var(--line);
}
.clip-main { min-width: 0; display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: baseline; }
.clip-meta { grid-column: 1 / -1; }
.code-btn {
  background: none;
  border: 0;
  padding: 0;
  min-height: 44px;
  color: inherit;
  font-family: var(--display);
  font-size: 1.45rem;
  font-weight: 560;
  text-align: left;
}
.code-btn:hover { color: var(--brass); }
.clip-host { overflow-wrap: anywhere; font-weight: 600; }
.clip-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.clip-actions .ghost { min-height: 40px; padding: 0.35rem 0.75rem; }

dialog {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 20px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(28, 22, 18, 0.48); }
#qr-slot svg { width: min(300px, 70vw); height: auto; display: block; margin: 12px auto; background: #fffaf2; }
dialog form { margin: 12px 0 0; }

.toast {
  position: fixed;
  z-index: 5;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  max-width: min(420px, calc(100% - 32px));
  padding: 10px 12px 10px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bg);
  box-shadow: var(--shadow);
}
.toast button {
  min-height: 36px;
  background: transparent;
  color: inherit;
  border: 1px solid currentColor;
}

.skip {
  position: absolute;
  left: 12px;
  top: -48px;
  background: var(--paper);
  color: var(--ink);
  padding: 8px 12px;
  border-radius: 10px;
  z-index: 6;
}
.skip:focus { top: 12px; }

.noscript {
  margin: 0;
  padding: 12px 16px;
  background: #9c2f1e;
  color: #fffaf3;
}

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

[hidden] { display: none !important; }

::selection { background: #efd39a; color: #1c1408; }

@media (max-width: 800px) {
  .shell {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 24px 0 48px;
  }
  header { position: static; }
  h1 { font-size: clamp(3rem, 16vw, 4.2rem); }
  .toast {
    top: auto;
    right: 16px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 16px;
  }
}

@media (max-width: 560px) {
  .composer-row { flex-direction: column; }
  .composer-row button { width: 100%; }
  .ticket { grid-template-columns: 1fr; }
  .stub { border-left: 0; border-top: 1px dashed var(--line); }
  .clip { flex-direction: column; align-items: stretch; }
  .library-head { align-items: start; }
}

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

@media (forced-colors: active) {
  .primary, .ghost, .qr-hit { border: 1px solid ButtonText; }
  .stamp { border-color: CanvasText; }
}
