/* gencon-scheduler webapp — parchment-and-burgundy fantasy aesthetic.
 *
 * Pure CSS, no framework. Two web fonts via Google Fonts (Cinzel for
 * display headings, Inter for body). Dark mode via prefers-color-scheme.
 * Reduced motion respected for the dice spinner and pulse animation.
 */

:root {
  /* Light (parchment) */
  --bg-paper:   #f4ebd9;
  --bg-paper-2: #efe3cc;
  --ink:        #2a1f15;
  --ink-muted:  #6b5740;
  --accent:     #9c2b1f;       /* deep tavern burgundy */
  --accent-2:   #b8431f;       /* warmer ember secondary */
  --accent-ink: #fff7ea;       /* text-on-accent */
  --gold:       #b8943f;
  --good:       #5e7a2e;
  --bad:        #b8302d;
  --border:     #d9c8a8;
  --shadow:     24, 16, 8;     /* warm shadow rgb */

  --font-display: 'Cinzel', 'Trajan Pro', 'Cormorant Garamond', Georgia, serif;
  --font-body:    'Inter', ui-sans-serif, system-ui, -apple-system,
                  "Segoe UI", "Helvetica Neue", sans-serif;
  --font-mono:    ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

  --radius:     10px;
  --pad:        1.25rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg-paper:   #1a1410;
    --bg-paper-2: #221a13;
    --ink:        #f0e6d2;
    --ink-muted:  #b8a784;
    --accent:     #e89060;
    --accent-2:   #f0a070;
    --accent-ink: #221a13;
    --gold:       #d4a96a;
    --good:       #a3c97a;
    --bad:        #ef6c69;
    --border:     #3a2d20;
    --shadow:     0, 0, 0;
  }
}

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

html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  color: var(--ink);
  background:
    radial-gradient(ellipse at top left,
      rgba(184, 67, 31, 0.07), transparent 55%),
    radial-gradient(ellipse at bottom right,
      rgba(184, 148, 63, 0.06), transparent 60%),
    var(--bg-paper);
  background-attachment: fixed;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted color-mix(in srgb, var(--accent) 60%, transparent);
}
a:hover { border-bottom-style: solid; }

header, main, footer {
  max-width: 820px;
  margin: 0 auto;
  padding: var(--pad);
}

/* Hero header */
header {
  text-align: center;
  padding-top: 2.5rem;
  padding-bottom: 1rem;
}
header h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.75rem, 4vw, 2.4rem);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink);
}
header h1 a {
  color: inherit;
  border-bottom: none;
}
header .tagline {
  margin: 0.5rem 0 0;
  color: var(--ink-muted);
  font-style: italic;
  font-size: 1rem;
}
header::after {
  content: '';
  display: block;
  width: 64px;
  height: 0;
  border-top: 1px solid var(--border);
  margin: 1.25rem auto 0;
  position: relative;
}

/* Card system — used by main wrapper, intro, progress, result */
.card {
  background: var(--bg-paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem 1.75rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 4px 14px rgba(var(--shadow), 0.10),
    0 1px 3px rgba(var(--shadow), 0.06);
}
.card + .card { margin-top: 1.25rem; }
@media (prefers-color-scheme: dark) {
  .card {
    box-shadow:
      0 1px 0 rgba(255, 255, 255, 0.04) inset,
      0 6px 18px rgba(0, 0, 0, 0.4);
  }
}

main { padding-bottom: 1rem; }

h2 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.4rem;
  letter-spacing: 0.04em;
  margin: 0 0 0.75rem;
  color: var(--ink);
}
h3 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.1rem;
  letter-spacing: 0.04em;
  margin: 1.25rem 0 0.5rem;
  color: var(--ink);
}

p { margin: 0.5rem 0; }
.hint {
  color: var(--ink-muted);
  font-size: 0.92rem;
  font-style: italic;
}
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0,0,0,0); border: 0;
}

/* Banners (used on result page when schedule is empty etc.) */
.banner {
  padding: 0.9rem 1.1rem;
  border-radius: 6px;
  margin: 0.6rem 0 1.2rem;
  border-left: 4px solid var(--accent, #b08b3a);
  background: var(--surface-2, #f6efdc);
  color: var(--ink, #2a2418);
  font-size: 0.95rem;
  line-height: 1.45;
}
.banner-warn {
  border-left-color: #c2741f;
  background: #fbe9c8;
  color: #4d2f0a;
}
.banner code {
  background: rgba(0, 0, 0, 0.06);
  padding: 0.05rem 0.35rem;
  border-radius: 3px;
  font-size: 0.9em;
}

/* Forms */
textarea {
  width: 100%;
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.5;
  background: color-mix(in srgb, var(--bg-paper) 75%, white);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  resize: vertical;
  min-height: 18em;
  box-shadow: inset 0 1px 2px rgba(var(--shadow), 0.06);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
@media (prefers-color-scheme: dark) {
  textarea {
    background: color-mix(in srgb, var(--bg-paper-2) 80%, black);
  }
}
textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow:
    inset 0 1px 2px rgba(var(--shadow), 0.06),
    0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

/* Buttons */
button, .button {
  display: inline-block;
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 70%, black);
  border-radius: 6px;
  padding: 0.6em 1.15em;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 0.82rem;
  cursor: pointer;
  text-decoration: none;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 1px 2px rgba(var(--shadow), 0.18);
  transition: transform 0.06s ease, box-shadow 0.15s ease,
              filter 0.15s ease;
}
button:hover, .button:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.08) inset,
    0 3px 8px rgba(var(--shadow), 0.22);
  filter: brightness(1.04);
  text-decoration: none;
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 70%, black);
}
button:active, .button:active {
  transform: translateY(0);
  filter: brightness(0.96);
}
button:disabled, .button:disabled {
  opacity: 0.5; cursor: progress; filter: grayscale(0.2);
  transform: none;
}
.button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  box-shadow: none;
}
.button.secondary:hover {
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.actions {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  margin-top: 0.85rem;
}
.actions.center { justify-content: center; }

/* Intro card on the home page */
.intro p { margin: 0.6rem 0; color: var(--ink); }
.intro p:first-child { margin-top: 0; }

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

.progress h2 {
  display: flex; align-items: center; gap: 0.75rem;
  margin-top: 0;
}

/* Hand-drawn-ish stepper */
.phases {
  list-style: none;
  padding: 0;
  margin: 1.25rem 0 1rem;
  display: flex;
  align-items: center;
  gap: 0;
  font-size: 0.78rem;
  flex-wrap: wrap;
}
.phases li {
  display: flex; align-items: center; gap: 0.55rem;
  font-family: var(--font-display);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-muted);
  white-space: nowrap;
}
.phases li::before {
  content: '';
  width: 14px; height: 14px;
  border: 1.5px solid var(--border);
  background: var(--bg-paper);
  border-radius: 60% 40% 55% 45% / 50% 60% 40% 50%;
  flex: 0 0 auto;
  transition: background 0.2s ease, border-color 0.2s ease;
}
.phases li:not(:last-child) {
  margin-right: 0.4rem;
}
.phases li:not(:last-child)::after {
  content: '';
  width: 1.75rem;
  height: 0;
  border-top: 1.5px dashed var(--border);
  margin-left: 0.55rem;
  flex: 0 0 auto;
}
.phases li.done {
  color: color-mix(in srgb, var(--ink) 80%, var(--gold));
}
.phases li.done::before {
  background: var(--gold);
  border-color: color-mix(in srgb, var(--gold) 60%, var(--ink));
}
.phases li.active {
  color: var(--accent);
  font-weight: 700;
}
.phases li.active::before {
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 60%, black);
  animation: pulseGlow 1.6s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 50%, transparent);
  }
  50% {
    box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent);
  }
}

/* Stepper layout on small screens */
@media (max-width: 600px) {
  .phases {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }
  .phases li {
    margin-right: 0;
  }
  .phases li:not(:last-child)::after {
    display: none;
  }
}

/* Rolling-d20 spinner */
.dice {
  color: var(--accent);
  flex: 0 0 auto;
  animation: rollDice 3.6s cubic-bezier(0.6, 0.05, 0.4, 1) infinite;
  transform-origin: 50% 50%;
}
.dice text {
  font-family: var(--font-display);
}
@keyframes rollDice {
  0%   { transform: rotate(0deg); }
  35%  { transform: rotate(140deg); }
  50%  { transform: rotate(160deg); }   /* tiny "settle" pause */
  85%  { transform: rotate(340deg); }
  100% { transform: rotate(360deg); }
}
.progress.errored .dice {
  animation: none;
  opacity: 0.45;
  color: var(--ink-muted);
}

@media (prefers-reduced-motion: reduce) {
  .dice { animation: none; }
  .phases li.active::before { animation: none; }
}

/* Log pane */
#log {
  background: color-mix(in srgb, var(--bg-paper) 60%, white);
  color: color-mix(in srgb, var(--ink) 90%, transparent);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  padding: 0.85rem 1rem;
  max-height: 22em;
  overflow: auto;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 2px rgba(var(--shadow), 0.05);
  scrollbar-color: var(--gold) transparent;
}
@media (prefers-color-scheme: dark) {
  #log {
    background: color-mix(in srgb, var(--bg-paper-2) 70%, black);
  }
}

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

.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem 1.5rem;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bg-paper) 80%, white),
    var(--bg-paper-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.4rem;
  margin: 1rem 0 1.25rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
@media (prefers-color-scheme: dark) {
  .summary {
    background: linear-gradient(180deg,
      var(--bg-paper-2),
      color-mix(in srgb, var(--bg-paper-2) 85%, black));
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  }
}
.summary div { display: flex; flex-direction: column; gap: 0.1rem; }
.summary dt {
  font-family: var(--font-display);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--ink-muted);
}
.summary dd {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.paste {
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.45;
  background: color-mix(in srgb, var(--bg-paper) 60%, white);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.85rem 1rem;
  max-height: 32em;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: inset 0 1px 2px rgba(var(--shadow), 0.05);
}
@media (prefers-color-scheme: dark) {
  .paste {
    background: color-mix(in srgb, var(--bg-paper-2) 70%, black);
  }
}

.result.errored pre {
  background: color-mix(in srgb, var(--bg-paper) 70%, white);
  border-left: 3px solid var(--bad);
  border-radius: 6px;
  padding: 0.85rem 1rem;
  white-space: pre-wrap;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

/* ---- Footer / coffee QR card ---- */

footer {
  margin-top: 2.5rem;
  padding-top: 1rem;
  text-align: center;
  color: var(--ink-muted);
  font-size: 0.9rem;
}
.coffee {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin: 0 auto 1rem;
  padding: 1rem 1.25rem;
  background: var(--bg-paper-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 2px 6px rgba(var(--shadow), 0.08);
}
.coffee img {
  border: 1px solid var(--border);
  border-radius: 4px;
  background: #fff;     /* always white so the QR scans */
  padding: 6px;
  display: block;
}
.coffee p {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink);
}
.meta {
  margin: 0.75rem 0 0;
  font-size: 0.82rem;
  color: var(--ink-muted);
  font-style: italic;
}

@media (max-width: 540px) {
  header, main, footer { padding: 0.85rem; }
  .card { padding: 1.15rem 1.1rem; }
  .summary { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); }
  header h1 { font-size: 1.6rem; }
}
