/* IQ Logic, iq.lookbookai.app (BRO-1496). The page is the test paper: an engineering pad and black
   ink, one red pen that marks it, and a green chalkboard after dark. No script, no outside request: every
   file is next to this one (front door CSP). */

@font-face { font-family: "Fraunces"; src: url("fraunces-regular.woff2") format("woff2"); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("fraunces-italic.woff2") format("woff2"); font-weight: 400; font-style: italic; font-display: swap; }
@font-face { font-family: "Fraunces"; src: url("fraunces-semibold.woff2") format("woff2"); font-weight: 600; font-style: normal; font-display: swap; }

:root {
  /* An engineering pad: pale green paper, a green grid, black ink. */
  --paper: #e9efe2;
  --paper-raised: #f6f9f1;
  --grid: rgba(46, 110, 70, 0.10);
  --grid-major: rgba(46, 110, 70, 0.19);
  --ink: #17201a;
  --ink-soft: #4a564c;
  --rule: rgba(23, 32, 26, 0.24);
  --pen: #c8352a;
  --shadow: 0 1px 0 rgba(23, 32, 26, 0.08), 0 14px 30px -18px rgba(23, 32, 26, 0.4);
  --serif: "Fraunces", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --mono: ui-monospace, "Cascadia Mono", "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  /* A classroom chalkboard: green slate, chalk white, red chalk for the marks. */
  :root {
    --paper: #1d2b24;
    --paper-raised: #24342c;
    --grid: rgba(230, 240, 225, 0.04);
    --grid-major: rgba(230, 240, 225, 0.075);
    --ink: #eceee2;
    --ink-soft: #a9b5a8;
    --rule: rgba(236, 238, 226, 0.2);
    --pen: #ff8a7a;
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.35), 0 18px 34px -20px rgba(0, 0, 0, 0.75);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  color: var(--ink);
  background-color: var(--paper);
  /* Graph paper: a 24px grid with a heavier line every five squares. */
  background-image:
    linear-gradient(var(--grid-major) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-major) 1px, transparent 1px),
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 120px 120px, 120px 120px, 24px 24px, 24px 24px;
  font-family: var(--serif);
  font-size: 18px;
  line-height: 1.55;
  font-optical-sizing: auto;
}

a { color: inherit; }

.sheet {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 32px;
}

.qno, .form-line, .fill-in, .aside, .turn, .num, figcaption, .imprint, .paper-head {
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.02em;
}

/* Masthead: the top of a test booklet. */
.masthead {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 22px 0 16px;
  border-bottom: 2px solid var(--ink);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 600;
  font-size: 19px;
  white-space: nowrap;
}

.brand img { border-radius: 7px; }

.form-line { margin: 0; color: var(--ink-soft); }
.form-line i, .imprint i { font-style: normal; padding: 0 6px; color: var(--rule); }

.fill-in {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: 8px;
  color: var(--ink-soft);
}

.fill-in b {
  display: inline-block;
  width: 120px;
  border-bottom: 1px solid var(--ink);
  margin-right: 14px;
}

.fill-in b:last-child { width: 80px; margin-right: 0; }

/* Opening: question 1, as the paper sets it. */
.opening {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 470px);
  gap: 64px;
  align-items: start;
  padding: 72px 0 88px;
}

.qno {
  margin: 0 0 18px;
  color: var(--pen);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0 0 28px;
  font-weight: 600;
  font-size: clamp(42px, 5.6vw, 72px);
  line-height: 1.02;
  letter-spacing: -0.02em;
}

h1 em {
  font-weight: 400;
  font-style: italic;
  color: var(--ink-soft);
}

.instructions {
  max-width: 34em;
  margin: 0 0 34px;
  padding-left: 18px;
  border-left: 2px solid var(--ink);
}

/* Store links as the answer bubbles of a marking sheet. */
.answers {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.bubble {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  padding: 8px 22px 8px 14px;
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  background: var(--paper-raised);
  text-decoration: none;
  font-weight: 600;
  font-size: 18px;
  line-height: 1.1;
  transition: background-color 0.15s ease, transform 0.15s ease;
}

.bubble small {
  display: block;
  font-family: var(--mono);
  font-weight: 400;
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--ink-soft);
}

.bubble .dot {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  flex: none;
  transition: background-color 0.15s ease;
}

.bubble:hover .dot, .bubble:focus-visible .dot { background: var(--ink); }
.bubble:hover { transform: translateY(-1px); }
.bubble:focus-visible { outline: 3px solid var(--pen); outline-offset: 3px; }

.aside {
  margin: 18px 0 0;
  color: var(--ink-soft);
}

/* The puzzle sheet. */
.paper {
  margin: 0;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}

.puzzle {
  position: relative;
  padding: 22px 26px 20px;
  transform: rotate(0.8deg);
}

.paper-head {
  display: flex;
  gap: 14px;
  margin: 0 0 18px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
  color: var(--ink-soft);
}

.paper-head span:first-child { color: var(--ink); font-weight: 700; }

.matrix, .options svg, .key-fig {
  fill: none;
  stroke: var(--ink);
  stroke-width: 2.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.matrix { display: block; width: 100%; height: auto; }
.matrix .rule { stroke-width: 1.2; }
.matrix .fill, .options .fill { fill: var(--ink); stroke: none; }

.matrix .q {
  fill: var(--pen);
  stroke: none;
  font-family: var(--serif);
  font-style: italic;
  font-size: 54px;
  text-anchor: middle;
}

.options {
  list-style: none;
  margin: 20px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
}

.options li {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 2px 4px;
  border: 1px solid var(--rule);
}

.options svg { width: 100%; height: auto; stroke-width: 4; }
.options span { font-family: var(--mono); font-size: 12px; color: var(--ink-soft); }

.turn {
  margin: 16px 0 0;
  color: var(--ink-soft);
  text-align: right;
}

/* Red pen. */
.pen {
  font-family: var(--serif);
  font-style: italic;
  color: var(--pen);
}

/* Part B: the paper's questions, ruled like exam lines. */
.paper-body { padding: 0 0 96px; }

h2 {
  margin: 0 0 30px;
  font-weight: 600;
  font-size: clamp(30px, 3.4vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.01em;
}

h2 .qno { display: block; margin-bottom: 10px; }

.items {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 2px solid var(--ink);
}

.items li {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) 190px;
  gap: 24px;
  align-items: baseline;
  padding: 26px 0 24px;
  border-bottom: 1px solid var(--rule);
}

.num {
  font-size: 15px;
  color: var(--ink-soft);
}

.items h3 {
  margin: 0 0 6px;
  font-weight: 600;
  font-size: 24px;
  line-height: 1.2;
}

.items p { margin: 0; max-width: 36em; color: var(--ink-soft); }

.margin {
  font-size: 19px;
  line-height: 1.25;
  transform: rotate(-3deg);
  transform-origin: left center;
}

/* Appendix: screens, stapled to the back of the paper. */
.appendix { padding: 0 0 104px; }

.prints {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 32px;
  align-items: start;
}

.print {
  position: relative;
  margin: 0;
  padding: 12px 12px 14px;
  background: var(--paper-raised);
  border: 1px solid var(--rule);
  box-shadow: var(--shadow);
}

.print:nth-child(odd) { transform: rotate(-1.4deg); }
.print:nth-child(even) { transform: rotate(1.1deg) translateY(18px); }

/* The staple. */
.print::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 50%;
  width: 34px;
  height: 7px;
  margin-left: -17px;
  border: 2px solid var(--ink-soft);
  border-bottom: none;
  border-radius: 2px 2px 0 0;
}

.print img {
  display: block;
  width: 100%;
  height: auto;
  border: 1px solid var(--rule);
}

.print figcaption {
  margin-top: 10px;
  color: var(--ink-soft);
}

/* Graded: the score in red pen, then the call to hand it in. */
.graded {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 56px;
  align-items: center;
  padding: 72px 0 96px;
  border-top: 2px solid var(--ink);
}

.score {
  display: grid;
  place-items: center;
  width: 250px;
  height: 210px;
  color: var(--pen);
  border: 3px solid var(--pen);
  border-radius: 52% 48% 55% 45% / 50% 58% 42% 50%;
  transform: rotate(-6deg);
}

.score span {
  font-family: var(--serif);
  font-weight: 600;
  font-style: italic;
  font-size: 104px;
  line-height: 1;
}

.graded h2 { font-size: clamp(36px, 4.4vw, 56px); margin-bottom: 14px; }
.graded p { max-width: 32em; margin: 0 0 28px; color: var(--ink-soft); }
.graded .aside { margin: 18px 0 0; }

/* Footer: the answer key. */
.key {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px 48px;
  padding: 34px 0 40px;
  border-top: 2px solid var(--ink);
}

.key-answer .qno { margin-bottom: 10px; }

.key-line {
  display: flex;
  gap: 18px;
  align-items: center;
  max-width: 44em;
}

.key-line p { margin: 0; font-size: 16px; color: var(--ink-soft); }
.key-line b { color: var(--ink); }

.key-fig {
  width: 64px;
  height: 64px;
  flex: none;
  stroke-width: 3.4;
  border: 2px solid var(--pen);
  border-radius: 50%;
  padding: 6px;
}

.key-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 16px;
}

.key-links a { text-decoration-color: var(--rule); text-underline-offset: 3px; }
.key-links a:hover { color: var(--pen); text-decoration-color: currentColor; }

.imprint {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--ink-soft);
}

/* Narrow screens: one column, the paper reads top to bottom. */
@media (max-width: 900px) {
  .opening { grid-template-columns: 1fr; gap: 48px; padding: 48px 0 72px; }
  .puzzle { max-width: 470px; transform: rotate(0.5deg); }
  .prints { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 20px; }
  .graded { grid-template-columns: 1fr; gap: 32px; }
}

@media (max-width: 640px) {
  body { font-size: 17px; }
  .sheet { padding: 0 16px; }
  .masthead { grid-template-columns: 1fr auto; gap: 8px 16px; }
  .fill-in { display: none; }
  .form-line { text-align: right; font-size: 11px; }
  .form-line .form-a { display: none; }
  .puzzle { padding: 16px 16px 14px; transform: none; }
  .options { grid-template-columns: repeat(3, 1fr); }
  .items li { grid-template-columns: 44px minmax(0, 1fr); gap: 4px 14px; }
  .margin { grid-column: 2; margin-top: 6px; }
  .bubble { flex: 1 1 100%; justify-content: flex-start; }
  .score { width: 200px; height: 168px; }
  .score span { font-size: 82px; }
  .key { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .bubble, .bubble .dot { transition: none; }
  .bubble:hover { transform: none; }
}
