/* Theme fonts: self-hosted Latin subsets, fetched only when a theme uses them (see fonts/LICENSE.md) */

@font-face {
  font-family: "Lilita One";
  src: url(fonts/lilitaone.woff2) format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Bangers";
  src: url(fonts/bangers.woff2) format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Syncopate";
  font-weight: 700;
  src: url(fonts/syncopate.woff2) format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Anton";
  src: url(fonts/anton.woff2) format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url(fonts/spacemono.woff2) format("woff2");
  font-display: swap;
}

:root {
  color-scheme: light dark;

  --page: #ffffff;
  --card: #ffffff;
  --border: #ddddd9;
  --label: #8a8a86;
  --icon: #6e6e6a;
  --text: #1c1c1a;
  --title: var(--text);
  --field-label: var(--label);
  --focus: var(--text);
  --button: #1c1c1a;
  --button-text: #ffffff;
  --error: #c7372d;
  --press: rgb(0 0 0 / 0.06);

  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  /* Theme hooks, set per theme below */
  --display: var(--sans);
  --display-weight: 700;
  --display-size: 34px;
  --display-line: 41px;
  --display-tracking: -0.02em;
  --display-case: none;
  --display-style: normal;
  --title-shadow: none;
  --title-stroke: 0 transparent;
  --input-font: var(--sans);
  --input-weight: 600;
  --input-size: 28px;
  --button-font: var(--sans);
  --button-weight: 600;
  --button-size: 17px;
  --button-tracking: -0.01em;
  --button-case: none;
  --button-border: 0 solid transparent;
  --button-shadow: none;
  --button-stroke: 0 transparent;
  --stroke: 1px;
  --card-shadow: none;
  --card-band: none;
  --card-band-height: 0px;

  --gutter: 16px;
  --radius: 18px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #000000;
    --card: #1f1f1e;
    --border: #3a3a37;
    --label: #8e8e89;
    --icon: #a3a39e;
    --text: #ededea;
    --button: #ededea;
    --button-text: #000000;
    --error: #ff6b5f;
    --press: rgb(255 255 255 / 0.08);
  }
}

/* Platform baseline */

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

[hidden] {
  display: none !important;
}

html {
  background: var(--page);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--page);
  color: var(--text);
  font: 17px/1.35 var(--sans);
  -webkit-font-smoothing: antialiased;
}

button {
  font: inherit;
  color: inherit;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--focus) 55%, transparent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Layout: one screen, top-anchored so the output never shifts the controls */

.app {
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: 100%;
  max-width: 520px;
  min-height: 100dvh;
  margin: 0 auto;
  padding:
    calc(env(safe-area-inset-top, 0px) + 32px)
    calc(env(safe-area-inset-right, 0px) + var(--gutter))
    calc(env(safe-area-inset-bottom, 0px) + var(--gutter))
    calc(env(safe-area-inset-left, 0px) + var(--gutter));
}

@media (min-height: 760px) and (min-width: 600px) {
  .app {
    padding-top: 12vh;
  }
}

.head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.head h1 {
  margin: 0;
  color: var(--title);
  font-family: var(--display);
  font-size: var(--display-size);
  font-style: var(--display-style);
  font-weight: var(--display-weight);
  line-height: var(--display-line);
  letter-spacing: var(--display-tracking);
  text-transform: var(--display-case);
  text-shadow: var(--title-shadow);
  -webkit-text-stroke: var(--title-stroke);
  paint-order: stroke fill;
}

.sub {
  margin: 2px 0 0;
  color: var(--label);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

/* Glyph optically aligned with the right gutter and the title's cap height */
.dice {
  flex: none;
  margin: -2px -10px 0 0;
}

/* Input */

.form {
  display: flex;
  flex-direction: column;
}

.field {
  position: relative;
  display: flex;
  align-items: center;
  height: 64px;
  background: var(--card);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  transition: border-color 150ms ease;
}

.field:focus-within {
  border-color: color-mix(in srgb, var(--text) 40%, var(--border));
}

.field[data-invalid] {
  border-color: var(--error);
}

.field input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0 64px 0 18px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: var(--text);
  font: var(--input-weight) var(--input-size) / 1 var(--input-font);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  caret-color: var(--text);
  outline: none;
}

.field input::placeholder {
  color: var(--field-label);
  opacity: 1;
}

.unit {
  position: absolute;
  right: 20px;
  color: var(--field-label);
  font-size: 20px;
  font-weight: 500;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.field input:placeholder-shown + .unit {
  opacity: 0;
}

.error {
  min-height: 20px;
  margin: 8px 4px 10px;
  color: var(--error);
  font-size: 14px;
  line-height: 20px;
}

.generate {
  height: 56px;
  border: var(--button-border);
  border-radius: var(--radius);
  background: var(--button);
  color: var(--button-text);
  font: var(--button-weight) var(--button-size) / 1 var(--button-font);
  letter-spacing: var(--button-tracking);
  text-transform: var(--button-case);
  box-shadow: var(--button-shadow);
  -webkit-text-stroke: var(--button-stroke);
  paint-order: stroke fill;
  transition: transform 160ms var(--ease-out), opacity 160ms ease;
}

.generate:active {
  transform: scale(0.97);
}

@media (hover: hover) and (pointer: fine) {
  .generate:hover {
    opacity: 0.88;
  }
}

/* Output card (after the Claude iOS code block) */

.output {
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: opacity 250ms var(--ease-out), transform 250ms var(--ease-out);
}

@starting-style {
  .output {
    opacity: 0;
    transform: translateY(8px);
  }
}

.card {
  position: relative;
  background: var(--card-band) top / 100% var(--card-band-height) no-repeat, var(--card);
  border: var(--stroke) solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

/* Centred on the first line of text, glyph about 17px in from the corner */
.card .copy {
  position: absolute;
  top: 7px;
  right: 4px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--icon);
  transition: transform 160ms var(--ease-out), background-color 160ms ease;
}

.dice.icon-btn {
  color: var(--dice, var(--icon));
}

.icon-btn:active {
  transform: scale(0.92);
  background-color: var(--press);
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover {
    background-color: var(--press);
  }
}

.icon-btn svg {
  grid-area: 1 / 1;
  transition: opacity 200ms var(--ease-out), transform 200ms var(--ease-out), filter 200ms var(--ease-out);
}

.icon-btn .front {
  fill: var(--card);
}

.icon-btn [data-icon="check"],
.icon-btn[data-copied] [data-icon="copy"] {
  opacity: 0;
  transform: scale(0.7);
  filter: blur(3px);
}

.icon-btn[data-copied] [data-icon="check"] {
  opacity: 1;
  transform: none;
  filter: none;
}

.code {
  margin: 0;
  padding: 20px 16px;
  overflow-x: auto;
  color: var(--text);
  font: 14px/1.3 var(--mono);
  font-variant-ligatures: none;
  white-space: pre;
  tab-size: 2;
  overscroll-behavior-x: contain;
}

.note {
  margin: 0 4px;
  color: var(--label);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

/* Absolute, not fixed: Safari 26 tints its bars from fixed elements at the edges.
   The page never scrolls, so this covers the viewport all the same. */
.confetti {
  position: absolute;
  inset: 0;
  z-index: 100;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* iOS 18+ fires a haptic when a native switch toggles; keep it in the tree, invisible.
   Not position: fixed, which Safari 26 would sample to tint its bars. */
.haptic {
  position: absolute;
  left: -100px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

/* Theme change: the new design sweeps out from the die (app.js drives the clip) */
.theme-reveal::view-transition-old(root),
.theme-reveal::view-transition-new(root) {
  animation: none;
  mix-blend-mode: normal;
}

/* Themes. Face 6 of the die is the design above. */

/* 1 · Fried chicken: cream page, golden crumbs, red-and-white bucket stripes */
:root[data-theme="chicken"] {
  color-scheme: light;
  --page: #fff3dc;
  --card: #fffaf0;
  --border: #e6b36b;
  --label: #94653e;
  --icon: #7a4a26;
  --text: #3a1d0b;
  --title: #c8102e;
  --button: #c8102e;
  --button-text: #fff6e3;
  --error: #b3261e;
  --press: rgb(122 74 38 / 0.12);
  --display: "Lilita One", var(--sans);
  --display-weight: 400;
  --display-size: 46px;
  --display-line: 50px;
  --display-tracking: 0.01em;
  --title-shadow: 2px 2px 0 #f2a900;
  --input-font: "Lilita One", var(--sans);
  --input-weight: 400;
  --input-size: 32px;
  --button-font: "Lilita One", var(--sans);
  --button-weight: 400;
  --button-size: 22px;
  --button-tracking: 0.02em;
  --button-shadow: 0 4px 0 #8f0b20;
  --stroke: 2px;
  --card-band: repeating-linear-gradient(90deg, #c8102e 0 18px, #fffaf0 18px 36px);
  --card-band-height: 10px;
  --radius: 22px;
}

:root[data-theme="chicken"] body {
  background:
    radial-gradient(circle at 30% 40%, rgb(214 140 60 / 0.2) 0 1.6px, transparent 2.2px) 0 0 / 23px 23px,
    radial-gradient(circle at 70% 75%, rgb(214 140 60 / 0.14) 0 1.2px, transparent 1.8px) 0 0 / 31px 31px,
    var(--page);
}

:root[data-theme="chicken"] .generate:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #8f0b20;
}

/* 2 · Teenage Mutant Ninja Turtles: sewer-green halftone, comic panels, the four bandanas */
:root[data-theme="tmnt"] {
  color-scheme: dark;
  --page: #0f2a16;
  --card: #fff8dc;
  --border: #0b0b0b;
  --label: #a5d98f;
  --field-label: #77735e;
  --focus: #b6f07a;
  --icon: #1a1a1a;
  --dice: #b6f07a;
  --text: #121212;
  --title: #8bd13f;
  --button: linear-gradient(90deg, #1f6fd0 0 25%, #e3262e 25% 50%, #f7941d 50% 75%, #7e3fa6 75% 100%);
  --button-text: #ffffff;
  --error: #ffb4a6;
  --press: rgb(0 0 0 / 0.08);
  --display: "Bangers", var(--sans);
  --display-weight: 400;
  --display-size: 56px;
  --display-line: 56px;
  --display-tracking: 0.04em;
  --title-shadow: 4px 4px 0 #0b0b0b;
  --title-stroke: 2px #0b0b0b;
  --input-font: "Bangers", var(--sans);
  --input-weight: 400;
  --input-size: 36px;
  --button-font: "Bangers", var(--sans);
  --button-weight: 400;
  --button-size: 28px;
  --button-tracking: 0.08em;
  --button-case: uppercase;
  --button-border: 3px solid #0b0b0b;
  --button-shadow: 5px 5px 0 #0b0b0b;
  --button-stroke: 1.5px #0b0b0b;
  --stroke: 3px;
  --card-shadow: 5px 5px 0 #0b0b0b;
  --radius: 8px;
}

:root[data-theme="tmnt"] body {
  background: radial-gradient(rgb(139 209 63 / 0.13) 1.2px, transparent 1.7px) 0 0 / 10px 10px, var(--page);
}

:root[data-theme="tmnt"] .head h1 {
  transform: rotate(-2deg);
  transform-origin: left center;
}

:root[data-theme="tmnt"] .generate:active {
  transform: translate(3px, 3px);
  box-shadow: 2px 2px 0 #0b0b0b;
}

/* 3 · RÜFÜS DU SOL: desert night, a low sunrise glow, wide-tracked caps */
:root[data-theme="rufus"] {
  color-scheme: dark;
  --page: #09090b;
  --card: #111114;
  --border: rgb(243 237 228 / 0.14);
  --label: #9a9185;
  --icon: #d3cabd;
  --text: #f3ede4;
  --button: linear-gradient(100deg, #f26b3a, #f7b267);
  --button-text: #120c08;
  --error: #ff8a70;
  --press: rgb(255 255 255 / 0.06);
  --display: "Syncopate", var(--sans);
  --display-size: 27px;
  --display-line: 41px;
  --display-tracking: 0.16em;
  --input-font: "Syncopate", var(--sans);
  --input-weight: 700;
  --input-size: 24px;
  --button-font: "Syncopate", var(--sans);
  --button-weight: 700;
  --button-size: 13px;
  --button-tracking: 0.32em;
  --button-case: uppercase;
  --radius: 3px;
}

:root[data-theme="rufus"] body {
  background: radial-gradient(130% 55% at 50% 42%, rgb(242 107 58 / 0.2), transparent 70%), var(--page);
}

:root[data-theme="rufus"] .sub {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

:root[data-theme="rufus"] .title-text {
  display: none;
}

:root[data-theme="rufus"] .head h1::after {
  content: "PRË-RÜN";
}

/* 4 · Filament Coffee: the Track Club's crema, espresso and sock stripes (fctc.fun) */
:root[data-theme="filament"] {
  color-scheme: light;
  --page: #faf4e6;
  --card: #fffbf2;
  --border: #1c1410;
  --label: #5c4f43;
  --icon: #1c1410;
  --text: #1c1410;
  --button: #1c1410;
  --button-text: #faf4e6;
  --error: #e8442c;
  --press: rgb(28 20 16 / 0.08);
  --mono: "Space Mono", ui-monospace, monospace;
  --display: "Anton", var(--sans);
  --display-weight: 400;
  --display-size: 52px;
  --display-line: 56px;
  --display-tracking: 0.01em;
  --display-case: uppercase;
  --input-font: "Anton", var(--sans);
  --input-weight: 400;
  --input-size: 34px;
  --button-font: "Anton", var(--sans);
  --button-weight: 400;
  --button-size: 22px;
  --button-tracking: 0.06em;
  --button-case: uppercase;
  --stroke: 2px;
  --card-band: linear-gradient(to right, #ffd23f 0 33.3%, #ff7a30 33.3% 66.6%, #e8442c 66.6% 100%);
  --card-band-height: 8px;
  --radius: 12px;
}

/* 5 · Qantas: white, charcoal and a single confident red */
:root[data-theme="qantas"] {
  color-scheme: light;
  --page: #ffffff;
  --card: #ffffff;
  --border: #e3e3e3;
  --label: #6f6f6f;
  --icon: #323232;
  --dice: #df0000;
  --text: #323232;
  --title: #df0000;
  --button: #df0000;
  --button-text: #ffffff;
  --error: #b00000;
  --press: rgb(0 0 0 / 0.05);
  --display-weight: 800;
  --display-size: 36px;
  --display-tracking: 0.01em;
  --display-case: uppercase;
  --display-style: italic;
  --button-weight: 700;
  --button-tracking: 0;
  --radius: 8px;
}

@media (prefers-reduced-motion: reduce) {
  @starting-style {
    .output {
      transform: none;
    }
  }

  .generate:active,
  .icon-btn:active,
  :root[data-theme] .generate:active {
    transform: none;
  }
}
