/* ABOUTME: Layout for the hosted Page Roast pages: the entry field, the result
   ABOUTME: header, the live view, and the screenshot canvas that holds the stickers. */

:root {
  --roast-paper: #f3f1e8;
  --roast-ink: #252b29;
  --roast-muted: #61665c;
  --roast-line: #cfd0c4;
  --roast-accent: #ad83f5;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--roast-paper);
  color: var(--roast-ink);
  font: 400 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}
a { color: inherit; }
button, input { font: inherit; color: inherit; }
[hidden] { display: none !important; }

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

/* ---------------------------------------------------------------- home */

.roast-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.roast-form {
  display: flex;
  width: min(640px, 100%);
  border: 1.5px solid var(--roast-ink);
  border-radius: 10px;
  background: #fffdf6;
  box-shadow: 0 10px 30px #1017140f;
  overflow: hidden;
}
.roast-form:focus-within { box-shadow: 0 0 0 3px #ad83f54d, 0 10px 30px #1017140f; }
.roast-form input {
  flex: 1;
  min-width: 0;
  padding: 18px 20px;
  border: 0;
  background: transparent;
  font: 500 18px/1.3 ui-monospace, SFMono-Regular, Menlo, monospace;
  outline: none;
}
.roast-form input::placeholder { color: #9a9f93; }
.roast-form button {
  padding: 0 22px;
  border: 0;
  border-left: 1.5px solid var(--roast-ink);
  background: var(--roast-ink);
  color: #fffdf6;
  font-weight: 600;
  cursor: pointer;
}
.roast-form button:disabled { opacity: .6; cursor: progress; }
.roast-message { min-height: 1.5em; margin: 16px 0 0; color: var(--roast-muted); text-align: center; }
.roast-message.roast-error { color: #a12b2b; }

.roast-footer {
  padding: 18px 24px;
  text-align: center;
  color: var(--roast-muted);
  font: 500 12px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.roast-footer a { color: inherit; text-decoration: underline; text-underline-offset: 2px; }
.roast-footer a:hover { color: var(--roast-ink); }
.roast-version { opacity: .55; }
.roast-plan {
  padding: 2px 8px;
  border-radius: 999px;
  background: #ffe7a8;
  color: #6b4a00;
  white-space: nowrap;
}

/* -------------------------------------------------------------- result */

.roast-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 20px;
  padding: 16px 24px;
  border-bottom: 1px solid var(--roast-line);
  background: #fffdf6;
  position: sticky;
  top: 0;
  z-index: 5;
}
.roast-brand { font: 700 14px/1 ui-monospace, SFMono-Regular, Menlo, monospace; text-decoration: none; letter-spacing: .02em; }
.roast-headline { flex: 1; margin: 0; font: 500 14px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--roast-ink); min-width: 200px; }
.roast-actions { display: flex; gap: 8px; }
.roast-actions button, .roast-another {
  padding: 6px 12px;
  border: 1px solid var(--roast-ink);
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  text-decoration: none;
  font: 500 13px/1.2 system-ui, sans-serif;
}
.roast-actions button:hover, .roast-another:hover { background: #ece9dd; }

.roast-stage {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

/* The verdict card sits above the screenshot: four lines built from Jev's
   answers and code's counts, quoting the page. */
.roast-verdict {
  margin: 0 0 20px;
  padding: 22px 26px;
  border: 1.5px solid var(--roast-ink);
  border-radius: 10px;
  background: #fffdf6;
  box-shadow: 0 10px 30px #1017140f;
}
.roast-verdict-hero {
  margin: 0;
  font: 650 22px/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--roast-ink);
}
.roast-verdict-repeat {
  margin: 10px 0 0;
  font: 500 13px/1.5 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--roast-muted);
}
.roast-verdict-label {
  margin: 16px 0 4px;
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #655186;
}
.roast-verdict-quote {
  margin: 0;
  padding: 2px 0 2px 14px;
  border-left: 3px solid var(--roast-accent);
  font: 400 16px/1.5 Georgia, "Times New Roman", serif;
  font-style: italic;
  color: var(--roast-ink);
}
.roast-verdict-quote.roast-verdict-best { border-left-color: #79d9bf; }
mark.roast-phrase {
  background: transparent;
  border-bottom: 2px solid var(--roast-accent);
  color: inherit;
  font-style: inherit;
  font-weight: 650;
  text-decoration: none;
}
.roast-sticker-label mark.roast-phrase {
  font: 650 11px/1.45 system-ui, sans-serif;
  border-bottom-width: 2px;
}

/* The section rail sits beside the screenshot and scrolls to its section. */
.roast-layout { display: grid; grid-template-columns: 216px minmax(0, 1fr); gap: 0 20px; align-items: start; }
.roast-rail { position: sticky; top: 74px; display: flex; flex-direction: column; gap: 6px; }
.roast-rail-title {
  margin: 0 0 4px;
  font: 600 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--roast-muted);
}
.roast-rail-item {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px;
  border: 1px solid var(--roast-line);
  border-radius: 8px;
  background: #fffdf6;
  text-align: left;
  cursor: pointer;
}
.roast-rail-item:hover { border-color: var(--roast-ink); }
.roast-rail-name { font: 650 12px/1.3 system-ui, sans-serif; color: var(--roast-ink); }
.roast-rail-line { font: 400 11.5px/1.4 system-ui, sans-serif; color: var(--roast-muted); }
.roast-rail-item:focus-visible { outline: 2px solid #5477b0; }

.roast-marker.roast-pulse { animation: roast-pulse 1.3s ease 2; }
@keyframes roast-pulse {
  0% { border-color: var(--roast-accent); box-shadow: 0 0 0 0 #ad83f566; }
  50% { border-color: var(--roast-accent); box-shadow: 0 0 0 5px #ad83f533; }
  100% { border-color: transparent; box-shadow: 0 0 0 0 #ad83f500; }
}

.roast-caption {
  margin: 12px 4px 0;
  color: var(--roast-muted);
  font: 500 13px/1.4 ui-monospace, SFMono-Regular, Menlo, monospace;
}

.roast-live {
  width: 100%;
  aspect-ratio: 1440 / 900;
  border: 1px solid var(--roast-line);
  border-radius: 10px;
  overflow: hidden;
  background: #111;
}
.roast-live iframe { display: block; width: 100%; height: 100%; border: 0; }

/* The canvas keeps the screenshot's aspect ratio before the image arrives, so
   stickers can be placed by fraction the moment their judgments land. */
.roast-canvas {
  position: relative;
  width: 100%;
  /* An outline, not a border: the stacked tiles must be exactly as tall as the
     canvas, or stickers placed by fraction drift near the bottom of a long page. */
  outline: 1px solid var(--roast-line);
  border-radius: 10px;
  overflow: visible;
  background: #fff;
}
.roast-tiles { display: flex; flex-direction: column; width: 100%; height: 100%; border-radius: 10px; overflow: hidden; }
.roast-tiles img { display: block; width: 100%; height: auto; }
.roast-overlay { position: absolute; inset: 0; pointer-events: none; }

/* A static marker: the graded block's box, in fractions of the screenshot. */
.roast-marker {
  position: absolute;
  border: 2px solid transparent;
  border-radius: 3px;
  pointer-events: none;
  transition: border-color 120ms ease;
}
.roast-marker:hover, .roast-marker:focus-within { z-index: 3; }
.roast-marker.roast-active {
  z-index: 4;
  border-color: var(--roast-accent);
  box-shadow: 0 0 0 2px #faf8efb3, 0 0 0 5px #ad83f54d;
}
.roast-chips {
  position: absolute;
  display: flex;
  align-items: flex-start;
  gap: 4px;
  width: max-content;
}
.roast-chips.roast-gutter { left: calc(100% + 6px); top: -8px; }
.roast-chips.roast-inside { right: -6px; top: -40px; }

.roast-canvas.roast-landing .roast-sticker { animation: roast-land 320ms cubic-bezier(.2,.8,.2,1) both; }
@keyframes roast-land {
  from { opacity: 0; transform: translateY(-10px) scale(1.15); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .roast-canvas.roast-landing .roast-sticker { animation: none; }
  .roast-marker { transition: none; }
  .roast-marker.roast-pulse { animation: none; border-color: var(--roast-accent); }
}

@media (max-width: 1040px) {
  .roast-layout { grid-template-columns: 1fr; }
  .roast-rail { position: static; flex-direction: row; flex-wrap: wrap; }
  .roast-rail-title { flex-basis: 100%; }
}

@media (max-width: 640px) {
  .roast-head { padding: 12px 14px; }
  .roast-stage { padding: 12px 8px 32px; }
  .roast-form input { padding: 14px 14px; font-size: 16px; }
  .roast-verdict { padding: 16px 16px; }
  .roast-verdict-hero { font-size: 18px; }
}
