/* Kalam — a ruled exercise-book page.
   Every vertical measure is a multiple of --rule so text sits on the lines. */

:root {
  --paper: #fbfcff;
  --rules: #dbe5f4;
  --margin: #d0443b;
  --ink: #1f3a93;
  --text: #1f2430;
  --muted: #545d6e;
  --field-line: #9fb2d6;
  --focus: rgba(31, 58, 147, .05);
  --error: #b3261e;

  --rule: 32px;
  --gutter: 96px;          /* page edge → red margin line */
  --rule-offset: 23px;     /* where the line falls inside each band (≈ baseline) */
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #121a2b;
    --rules: #22304a;
    --margin: #b9504a;
    --ink: #9db4ff;
    --text: #e6e9f0;
    --muted: #a6aec0;
    --field-line: #3e5682;
    --focus: rgba(157, 180, 255, .07);
    --error: #ff8a80;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; min-height: 100%; }

body {
  margin: 0;
  color: var(--text);
  background-color: var(--paper);
  /* the ruled lines */
  background-image:
    linear-gradient(var(--margin), var(--margin)),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent calc(var(--rule-offset) - 1px),
      var(--rules) calc(var(--rule-offset) - 1px),
      var(--rules) var(--rule-offset),
      transparent var(--rule-offset),
      transparent var(--rule)
    );
  background-size: 2px 100%, 100% var(--rule);
  background-position: calc(var(--gutter) - 24px) 0, 0 0;
  background-repeat: no-repeat, repeat;
  font-family: "Hind", system-ui, sans-serif;
  font-size: 18px;
  line-height: var(--rule);
}

.page {
  max-width: calc(var(--gutter) + 680px);
  padding: calc(var(--rule) * 3) 24px calc(var(--rule) * 2) var(--gutter);
}

a { color: var(--ink); text-underline-offset: 4px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
a:focus-visible { outline: 2px solid var(--ink); outline-offset: 4px; border-radius: 2px; }

p, ul, h1, h2 { margin: 0; }

/* ---------- hero ---------- */

.word {
  position: relative;
  display: inline-block;
  font-family: "Tiro Devanagari Hindi", serif;
  font-size: 160px;
  line-height: calc(var(--rule) * 6);
  color: var(--ink);
  margin-left: -6px;
}

.stroke {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 26px;
  width: 100%;
  height: 28px;
  overflow: visible;
}

.stroke path {
  fill: none;
  stroke: var(--ink);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 640;
  stroke-dashoffset: 640;
  animation: write 1.1s 0.35s cubic-bezier(.6, .1, .3, 1) forwards;
}

@keyframes write { to { stroke-dashoffset: 0; } }

@media (prefers-reduced-motion: reduce) {
  .stroke path { animation: none; stroke-dashoffset: 0; }
}

h1 {
  font-family: "Tiro Devanagari Hindi", serif;
  font-weight: 400;
  font-size: 38px;
  line-height: calc(var(--rule) * 2);
}


.button {
  display: inline-block;
  padding: 0 22px;
  line-height: calc(var(--rule) * 1.5);
  background: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  border-radius: 999px;
}
.button:hover { filter: brightness(1.12); }

.quiet { margin-left: 20px; font-weight: 500; }

/* ---------- nav ---------- */

.nav {
  position: absolute;
  top: 0;
  right: 0;
  display: flex;
  gap: 24px;
  padding: 0 24px;
  line-height: var(--rule);
  margin-top: var(--rule);
  font-weight: 500;
}
.nav a { text-decoration: none; }
.nav a:hover { text-decoration: underline; }
body { position: relative; }

/* ---------- empty slots: spaces still to be written ---------- */

.slot {
  max-width: 36em;
  margin-top: var(--rule);
  padding: 0 14px;
  outline: 1.5px dashed var(--field-line);
  outline-offset: -1.5px;
  border-radius: 6px;
  color: var(--muted);
}
.slot b { display: block; font-weight: 600; color: var(--ink); }
.rows-1 { display: flex; align-items: center; height: calc(var(--rule) * 2); }
.rows-1 b { display: inline; margin-right: 8px; }
.rows-2 { min-height: calc(var(--rule) * 2); }
.rows-3 { min-height: calc(var(--rule) * 3); }
.rows-4 { min-height: calc(var(--rule) * 4); }

/* ---------- sections ---------- */

.block { margin-top: calc(var(--rule) * 4); }

h2, h3 {
  font-family: "Tiro Devanagari Hindi", serif;
  font-weight: 400;
  color: var(--ink);
}
h2 { font-size: 28px; line-height: calc(var(--rule) * 2); }
h3 { font-size: 24px; line-height: calc(var(--rule) * 2); margin: 0; }

/* ---------- tabs ---------- */

.tabs { display: flex; flex-wrap: wrap; gap: 0 28px; margin-top: var(--rule); }
.tabs button {
  font: inherit;
  font-weight: 500;
  line-height: var(--rule);
  color: var(--muted);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  /* the selected tab gets an ink underline drawn on the rule */
  background-image: linear-gradient(var(--ink), var(--ink));
  background-repeat: no-repeat;
  background-position: 0 calc(var(--rule-offset) + 2px);
  background-size: 0 2px;
  transition: background-size .25s ease, color .25s ease;
}
.tabs button[aria-selected="true"] { color: var(--ink); background-size: 100% 2px; }
.tabs button:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

/* ---------- forms: written on the lines ---------- */

.sheet { max-width: 36em; }
.field { border: 0; padding: 0; margin: var(--rule) 0 0; min-width: 0; }
.field label, .field legend { display: block; padding: 0; font-weight: 500; color: var(--text); }
.opt { font-weight: 400; color: var(--muted); }

.field input, .field textarea {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0 2px;
  border: 0;
  border-radius: 0;
  font: inherit;
  line-height: var(--rule);
  color: var(--ink);
  background: transparent;
  appearance: none;
}
.field input {
  height: var(--rule);
  /* a stronger line on the rule shows where to write */
  background-image: linear-gradient(var(--field-line), var(--field-line));
  background-repeat: no-repeat;
  background-position: 0 calc(var(--rule-offset) - 1px);
  background-size: 100% 1.5px;
}
.field textarea {
  resize: vertical;
  background-image: repeating-linear-gradient(to bottom,
    transparent 0, transparent calc(var(--rule-offset) - 1px),
    var(--field-line) calc(var(--rule-offset) - 1px), var(--field-line) calc(var(--rule-offset) + .5px),
    transparent calc(var(--rule-offset) + .5px), transparent var(--rule));
}
.field input::placeholder, .field textarea::placeholder { color: var(--muted); opacity: .7; }
.field input:focus, .field textarea:focus { outline: none; --field-line: var(--ink); background-color: var(--focus); }
.field [aria-invalid="true"] { --field-line: var(--error); }

.chips { display: flex; flex-wrap: wrap; gap: 0 8px; }
.chips label {
  display: inline-flex;
  align-items: center;
  height: 26px;
  margin: 3px 0;
  padding: 0 12px;
  border: 1.5px solid var(--field-line);
  border-radius: 999px;
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  background: var(--paper);
  cursor: pointer;
  user-select: none;
}
.chips input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.chips label:has(input:checked) { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.chips label:has(input:focus-visible) { outline: 2px solid var(--ink); outline-offset: 2px; }
.field[aria-invalid="true"] .chips label { border-color: var(--error); }

.consent { display: flex; gap: 10px; align-items: flex-start; margin-top: var(--rule); color: var(--muted); cursor: pointer; }
.consent input { flex: none; width: 18px; height: 18px; margin: 6px 0 0; accent-color: var(--ink); }
.consent.invalid span { color: var(--error); }

.trap { position: absolute; left: -9999px; width: 1px; height: 1px; }

.error { margin-top: var(--rule); color: var(--error); font-weight: 500; }
.sheet .button { margin: var(--rule) 0 16px; border: 0; font: inherit; font-weight: 600; line-height: calc(var(--rule) * 1.5); cursor: pointer; }
.sheet .button[disabled] { opacity: .6; cursor: progress; }
.button:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.done { margin-top: var(--rule); max-width: 36em; outline: none; }
.done p { color: var(--muted); }

.foot {
  margin-top: calc(var(--rule) * 5);
  color: var(--muted);
  font-size: 15px;
}

/* ---------- small screens ---------- */

@media (max-width: 640px) {
  :root { --gutter: 44px; --rule: 30px; --rule-offset: 22px; }
  body { font-size: 17px; background-position: calc(var(--gutter) - 14px) 0, 0 0; }
  .page { padding-right: 16px; padding-top: calc(var(--rule) * 3); }
  .word { font-size: 104px; line-height: calc(var(--rule) * 4); }
  .stroke { bottom: 14px; height: 20px; }
  h1 { font-size: 29px; }
  h2 { font-size: 25px; }
}
