/*
 * App views — the topbar parts (app/chrome.js), /login (views/login.js) and
 * /cvs (views/cvs.js).
 *
 * Lecture Notebook world: squared paper (.nb-grid), index tabs, the red
 * margin rule, stamps whose line form carries state (solid = done, dashed =
 * pending, struck = cancelled). The highlighter (.hl) only ever marks text
 * the AI wrote. The CV sheet itself is always white paper (engine CSS).
 *
 * Tokens only (tokens.css) · logical properties only (RTL-first, LTR-safe) ·
 * touch targets >= 40px · motion limited to tab pull, highlighter sweep,
 * stamp press and state transitions (base.css honours reduced motion).
 *
 * Class prefixes: .tb-* topbar · .lg-* login · .otp* code field ·
 *                 .cvs-* My CVs · .nc-* New-CV dialog
 */

/* =========================================================================
 * Topbar (base.css owns .topbar / .brand / .beta; these are the parts)
 * ======================================================================= */
.tb .brand { flex: none; min-width: 0; }
.tb .brand img { flex: none; }
.brand-text { display: grid; line-height: 1.25; }
.brand-name { font-weight: 600; white-space: nowrap; }
.brand-sub { display: inline-flex; align-items: center; gap: 7px; }
.brand .brand-sub small { display: inline; }
.brand .beta { line-height: 1.45; }

/* compact (studio): logo only; the name stays for assistive tech */
.brand.is-compact .brand-name,
.brand.is-compact .brand-sub small {
  position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.tb-back { flex: none; gap: 6px; padding-inline: 10px 14px; }
.tb-title {
  flex: 0 1 auto;
  min-width: 0;
  display: flex; align-items: center;
  min-height: 28px;
  padding-inline-start: 12px;
  border-inline-start: 1px solid var(--line);
  color: var(--ink);
  font-weight: 500;
}
.tb-title > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tb-tools { flex: none; display: flex; align-items: center; gap: 2px; }
.tb-actions { flex: none; display: flex; align-items: center; gap: 8px; }
.tb-lang { gap: 6px; padding-inline: 12px; font-size: var(--fs-sm); }
.tb-lang-short { display: none; font-weight: 600; }

/* who is signed in, at the top of the account menu */
.menu-head {
  display: grid; gap: 1px;
  padding: 6px 10px 10px;
  margin-block-end: 4px;
  border-block-end: 1px solid var(--line);
}
.menu-head strong { font-size: var(--fs-sm); font-weight: 600; color: var(--ink); overflow-wrap: anywhere; }
.menu-email { justify-self: start; font-size: var(--fs-xs); color: var(--ink-3); overflow-wrap: anywhere; }

@media (max-width: 899.98px) {
  .brand.is-compact .beta { display: none; }
}
@media (max-width: 559.98px) {
  .tb { gap: 8px; padding-inline: 12px; }
  .tb.has-user .tb-fold { display: none; }        /* folded into the account menu */
  .tb-back { width: 40px; padding: 0; }
  .tb-back-label,
  .tb-lang-full {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .tb-lang { padding-inline: 10px; }
  .tb-lang-short { display: inline; }
  .tb-title { padding-inline-start: 8px; }
}

/* Pages sit on the desk; notebook pages and the white sheet lie on top. */
.lg-page,
.cvs-page {
  min-height: 100dvh;
  display: flex; flex-direction: column;
  background: color-mix(in srgb, var(--desk) 38%, var(--paper));
}

/* =========================================================================
 * /login
 * ======================================================================= */
.lg-main { flex: 1; padding: 20px 16px 40px; }
.lg-grid {
  max-width: 1160px;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 40px;
}
.lg-auth { width: 100%; max-width: 520px; margin-inline: auto; padding-block-start: 10px; }

/* the steps are index tabs tucked behind the page; the current one is pulled out */
.lg-steps {
  display: flex; gap: 4px;
  margin: 0; padding: 0;
  padding-inline-start: 52px;
  list-style: none;
}
.lg-steps li {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 30px;
  padding: 4px 12px 8px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  background: var(--paper-3);
  color: var(--ink-2);            /* --ink-3 on --paper-3 is below 4.5:1 */
  font-size: var(--fs-xs); font-weight: 500;
  box-shadow: var(--shadow-tab);
  transform: translateY(6px);
  transition: transform var(--t-med) var(--ease-out), background-color var(--t-fast), color var(--t-fast);
}
.lg-steps li.is-done { background: var(--paper-2); color: var(--ink-2); }
.lg-steps li[aria-current="step"] { background: var(--violet); color: var(--violet-ink); transform: translateY(0); }
.lg-steps svg { width: 14px; height: 14px; }
.lg-step-n { font-weight: 600; font-variant-numeric: tabular-nums; }

/* the notebook page holding the form */
.lg-card {
  position: relative;
  z-index: 1;
  padding: 28px 26px 26px;
  padding-inline-start: 62px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sheet);
}
.lg-card::before { /* the red margin rule */
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 40px;
  width: 1.5px;
  background: var(--margin);
  opacity: 0.55;
  pointer-events: none;
}

.lg-form { display: grid; gap: 18px; }
.lg-title { font-size: var(--fs-2xl); font-weight: 600; }
.lg-title:focus { outline: none; }
.lg-lead { margin-block-start: -8px; color: var(--ink-2); }
.lg-note { display: flex; align-items: flex-start; gap: 8px; font-size: var(--fs-sm); color: var(--ink-3); }
.lg-note svg { width: 16px; height: 16px; margin-block-start: 3px; }
.lg-mail { font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }
.lg-who {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px;
  padding: 8px 12px;
  border: 1px dashed var(--rule);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: var(--fs-sm);
  color: var(--ink-2);
}
.lg-who svg { width: 16px; height: 16px; color: var(--ink-3); }
.lg-who .lg-link { margin-inline-start: auto; }

/* inline text button (change email …): link look, generous hit area */
.lg-link {
  display: inline-flex; align-items: center;
  min-height: 40px;
  margin-block: -10px;
  padding: 0 4px;
  border: 0;
  background: none;
  color: var(--primary);
  font-size: inherit; font-weight: 500;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
.lg-link:hover { text-decoration-thickness: 2px; }

.lg-req { color: var(--bad); font-weight: 600; }
.lg-optional {
  display: grid; gap: 12px;
  margin: 0;
  padding: 12px 0 0;
  border: 0;
  border-block-start: 1px dashed var(--rule);
}
.lg-optional legend { padding-inline-end: 8px; font-size: var(--fs-sm); font-weight: 500; color: var(--ink-3); }
.lg-optional-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
.lg-terms { display: grid; gap: 4px; }
.lg-terms .err { padding-inline-start: 28px; }
.lg-resend[disabled] { opacity: 1; color: var(--ink-3); }
.lg-resend bdi { margin-inline-start: 4px; }

/* ---- the 6-digit code: one real input over six painted boxes ---------------- */
.otp {
  position: relative;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  max-width: 360px;
}
.otp-cell {
  position: relative;
  display: grid; place-items: center;
  height: 56px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: 24px; font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: border-color var(--t-fast) var(--ease-out), box-shadow var(--t-fast) var(--ease-out);
}
.otp-cell.is-filled { border-color: var(--ink-3); }
.otp:focus-within .otp-cell.is-active {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
.otp:focus-within .otp-cell.is-active:not(.is-filled)::after { /* static caret, no blinking */
  content: "";
  width: 2px; height: 24px;
  border-radius: 1px;
  background: var(--primary);
}
.otp:has(.otp-input[aria-invalid="true"]) .otp-cell { border-color: var(--bad); }
.otp-input {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  margin: 0; padding: 0;
  border: 0;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  caret-color: transparent;
  font-size: 16px; /* >= 16px: no iOS zoom on focus */
  cursor: text;
}
.otp-input:focus,
.otp-input:focus-visible { outline: none; } /* the active box shows focus */
.otp-input::selection { background: transparent; }

/* ---- what's new: a column that demonstrates the product -------------------- */
.lg-new {
  width: 100%; max-width: 560px;
  margin-inline: auto;
  display: grid; gap: 10px; align-content: start;
  padding-block-start: 28px;
  border-block-start: 1px dashed var(--rule);
}
/* the spread: margin notes (inline-start) written beside the sample sheet */
.lg-spread { display: grid; gap: 28px; align-items: start; }
.lg-notes {
  position: relative;
  margin: 0; padding: 0; padding-inline-start: 44px;
  list-style: none;
  display: grid; gap: 0;
  /* ruled notebook lines under the notes, with the red margin rule */
  background-image: linear-gradient(transparent calc(100% - 1px), var(--rule) calc(100% - 1px));
  background-size: 100% 28px;
}
.lg-notes::before {
  content: ""; position: absolute; inset-block: 0; inset-inline-start: 30px;
  width: 1.5px; background: var(--margin); opacity: 0.55;
}
.lg-mnote { position: relative; padding-block: 0 28px; } /* text sits on the 28px ruling; one blank ruled line between notes */
.lg-mnote-n {
  position: absolute; inset-inline-start: -44px; inset-block-start: 3px;
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--violet); color: var(--violet);
  font-size: 12px; font-weight: 600; line-height: 1;
}
.lg-mnote-t { display: block; font-size: var(--fs-md); font-weight: 600; line-height: 28px; }
.lg-mnote p { font-size: var(--fs-sm); line-height: 28px; color: var(--ink-2); max-width: 46ch; }

/* the SAMPLE sheet: true-A4 pages rendered by the engine, scaled into the box */
.lg-sample-block { display: grid; justify-items: center; gap: 14px; }
.lg-sample { width: min(300px, 100%); margin: 0; }
.lg-sheet-wrap { position: relative; padding-block-start: 12px; }
.lg-sheet {
  --s: 0.36;
  /* white paper in both themes, so its highlighter keeps the light yellow (same pin as .sheet-frame) */
  --highlight: rgba(255, 224, 70, 0.78);
  position: relative;
  aspect-ratio: 210 / 297;
  overflow: hidden;
  border-radius: 2px;
  background: #fff; /* the CV sheet is always white paper, in both themes */
  outline: 1px solid var(--line);
  box-shadow: var(--shadow-sheet);
}
.lg-sheet-host {
  position: absolute;
  inset-block-start: 0;
  inset-inline-start: 0;
  width: 210mm;
  visibility: hidden;          /* rendered unscaled first, then shown scaled */
  transform-origin: top right;
}
[dir="ltr"] .lg-sheet-host { transform-origin: top left; }
.lg-sheet.is-ready .lg-sheet-host { visibility: visible; transform: scale(var(--s)); }
.lg-sheet-host .cv-page ~ .cv-page { display: none; } /* first page only */
.lg-sample-stamp {
  position: absolute;
  inset-block-start: 0;
  inset-inline-end: 10px;
  z-index: 2;
  padding: 3px 10px;
  background: var(--paper);
  font-size: var(--fs-xs);
}
.lg-mark {
  position: absolute; z-index: 2;
  inset-inline-start: -11px; transform: translateY(-50%);
  display: grid; place-items: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--violet); color: var(--violet-ink);
  font-size: 12px; font-weight: 600; line-height: 1;
  box-shadow: var(--shadow-tab);
}
.lg-sample-cap { max-width: 44ch; font-size: var(--fs-xs); line-height: 1.75; color: var(--ink-3); text-align: center; }

.lg-foot {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 0 20px;
  padding: 8px 16px 20px;
  font-size: var(--fs-sm);
}
.lg-foot a { display: inline-flex; align-items: center; min-height: 40px; color: var(--ink-2); }

@media (max-width: 479.98px) {
  .lg-card { padding: 22px 16px 20px; padding-inline-start: 42px; }
  .lg-card::before { inset-inline-start: 26px; }
  .lg-steps { padding-inline-start: 36px; }
  .lg-steps li { padding-inline: 10px; }
  .lg-title { font-size: var(--fs-xl); }
  .otp { gap: 6px; }
  .otp-cell { height: 52px; font-size: 22px; }
}
@media (min-width: 960px) {
  .lg-main { padding: 36px 32px 48px; }
  .lg-grid { grid-template-columns: minmax(0, 460px) minmax(0, 1fr); gap: 64px; align-items: start; }
  .lg-auth { max-width: none; margin: 0; }
  .lg-new { max-width: none; margin: 0; padding-block-start: 52px; border-block-start: 0; }
}
@media (min-width: 1180px) {
  .lg-spread { grid-template-columns: minmax(0, 1fr) 280px; gap: 40px; }
  .lg-sample { width: 100%; }
}

/* =========================================================================
 * /cvs — My CVs
 * ======================================================================= */
.cvs-main {
  flex: 1;
  width: 100%; max-width: 1180px;
  margin-inline: auto;
  padding: 22px 16px 56px;
  display: grid; gap: 20px; align-content: start;
}
.cvs-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px 24px; }
.cvs-head-text { min-width: 0; }
.cvs-title { font-size: var(--fs-2xl); }
.cvs-title:focus { outline: none; }
.cvs-lead { margin-block-start: 2px; color: var(--ink-2); }
.cvs-count { margin-block-start: 2px; font-size: var(--fs-sm); }

/* account strip: who you are + paid stamp or the price line (from /me) */
.cvs-acct {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 12px 24px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--paper);
}
.cvs-acct-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.cvs-acct-ic {
  flex: none;
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--violet-soft);
  color: var(--violet);
}
.cvs-acct-name { font-weight: 600; }
.cvs-acct-mail { display: block; font-size: var(--fs-xs); color: var(--ink-3); overflow-wrap: anywhere; }
.cvs-plan { display: grid; justify-items: start; gap: 4px; }
.cvs-plan .stamp { font-size: var(--fs-xs); }
.cvs-price { color: var(--ink-2); }
.cvs-price-old { color: var(--ink-3); text-decoration-thickness: 1.5px; }
.cvs-price-now { color: var(--ink); font-weight: 700; }
.cvs-plan-note { font-size: var(--fs-xs); color: var(--ink-3); }

/* the notebook pages */
.cvs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 264px), 1fr));
  gap: 40px 20px;
  margin: 0;
  padding: 22px 0 0;  /* room for the first row's index tabs */
  list-style: none;
}
.cvs-grid > li { display: grid; }
.cvs-card {
  position: relative;
  display: flex; flex-direction: column; gap: 6px;
  min-height: 212px;
  padding: 16px 14px 14px;
  padding-inline-start: 44px;
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-tab);
  transition: box-shadow var(--t-fast) var(--ease-out), border-color var(--t-fast) var(--ease-out);
}
.cvs-card::before { /* red margin rule */
  content: "";
  position: absolute;
  inset-block: 0;
  inset-inline-start: 28px;
  width: 1.5px;
  background: var(--margin);
  opacity: 0.5;
  pointer-events: none;
}
.cvs-card:not(.cvs-skel):hover { border-color: var(--line-strong); box-shadow: var(--shadow-sheet); }

/* the CV's language, as an index tab on the page's top edge (label + colour) */
.cvs-tab {
  position: absolute;
  inset-block-end: 100%;
  inset-inline-start: 40px;
  padding: 3px 12px 2px;
  border-radius: var(--r-sm) var(--r-sm) 0 0;
  font-size: var(--fs-xs); font-weight: 600; line-height: 1.5;
  box-shadow: var(--shadow-tab);
}
.cvs-tab.is-ar { background: var(--violet); color: var(--violet-ink); }
.cvs-tab.is-en { background: var(--teal); color: var(--teal-ink); }

.cvs-card-name {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
  padding-inline-end: 34px; /* clear of the ⋯ button */
  font-size: var(--fs-lg); font-weight: 600; line-height: 1.45;
  overflow-wrap: anywhere;
}
.cvs-card-link { color: var(--ink); text-decoration: none; }
.cvs-card-link::after { /* the whole page opens the CV */
  content: "";
  position: absolute; inset: 0; z-index: 1;
  border-radius: var(--r-md);
}
.cvs-card-link:focus-visible { outline: none; }
.cvs-card-link:focus-visible::after { outline: 2px solid var(--focus); outline-offset: 3px; }
.cvs-card:hover .cvs-card-link { text-decoration: underline; text-decoration-color: var(--rule); text-underline-offset: 4px; }
.cvs-card-headline { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: var(--fs-sm); color: var(--ink-2); }
.cvs-card-headline.is-empty { color: var(--ink-3); }
.cvs-card-meta { display: flex; align-items: center; gap: 6px; font-size: var(--fs-xs); color: var(--ink-3); }
.cvs-card-meta svg { width: 14px; height: 14px; }
.cvs-stamps {
  display: flex; flex-wrap: wrap; gap: 8px 6px;
  margin: 0; margin-block-start: auto;
  padding: 12px 0 0;
  border-block-start: 1px solid var(--rule);
  list-style: none;
}
.cvs-more { position: absolute; inset-block-start: 6px; inset-inline-end: 4px; z-index: 2; color: var(--ink-2); }

/* busy: the page is being copied / translated / deleted */
.cvs-card-busy {
  position: absolute; inset: 0; z-index: 3;
  display: grid; place-content: center; justify-items: center; gap: 10px;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  color: var(--ink-2);
  font-size: var(--fs-sm); font-weight: 500;
}
.cvs-spin {
  width: 22px; height: 22px;
  border: 2px solid var(--primary);
  border-inline-end-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* loading skeleton */
.cvs-skel { pointer-events: none; }
.cvs-skel .skeleton { display: block; }
.cvs-skel .sk-tab { position: absolute; inset-block-end: 100%; inset-inline-start: 40px; width: 56px; height: 20px; border-radius: var(--r-sm) var(--r-sm) 0 0; }
.cvs-skel .sk-name { width: 70%; height: 22px; margin-block-end: 4px; }
.cvs-skel .sk-line { width: 85%; height: 12px; }
.cvs-skel .sk-line.short { width: 45%; }
.cvs-skel .sk-stamps { display: flex; gap: 6px; margin-block-start: auto; padding-block-start: 12px; border-block-start: 1px solid var(--rule); }
.cvs-skel .sk-stamps .skeleton { width: 58px; height: 22px; }

/* empty notebook: a blank page that invites the first CV */
.cvs-empty {
  display: grid; justify-items: center; gap: 12px;
  width: 100%; max-width: 640px;
  margin: 12px auto 0;
  padding: 48px 20px 44px;
  border: 1.5px dashed var(--rule);
  border-radius: var(--r-lg);
  text-align: center;
}
.cvs-empty-ic {
  display: grid; place-items: center;
  width: 64px; height: 64px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--violet);
}
.cvs-empty-ic svg { width: 30px; height: 30px; }
.cvs-empty h2 { font-size: var(--fs-xl); }
.cvs-empty p { max-width: 46ch; color: var(--ink-2); }
.cvs-empty .btn { margin-block-start: 6px; }

.cvs-state { display: grid; justify-items: center; gap: 10px; padding: 48px 16px; text-align: center; color: var(--ink-2); }
.cvs-state svg { width: 32px; height: 32px; color: var(--bad); }

@media (min-width: 768px) {
  .cvs-main { gap: 24px; padding: 32px 24px 64px; }
}
@media (max-width: 479.98px) {
  .cvs-head > .btn { width: 100%; }
  .cvs-title { font-size: var(--fs-xl); }
}

/* =========================================================================
 * New-CV dialog
 * ======================================================================= */
.nc-form { display: grid; gap: 18px; }
.nc-seg { justify-self: start; }
.nc-seg button { min-height: 40px; padding: 6px 18px; font-size: var(--fs-md); }
.nc-start { display: grid; gap: 10px; margin: 0; padding: 0; border: 0; }
.nc-start legend { margin-block-end: 6px; padding: 0; }
.nc-opt {
  display: grid;
  grid-template-columns: auto 36px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1.5px solid var(--line-strong);
  border-radius: var(--r-md);
  background: var(--paper);
  cursor: pointer;
  transition: border-color var(--t-fast) var(--ease-out), background-color var(--t-fast) var(--ease-out);
}
.nc-opt:hover { border-color: var(--ink-3); }
.nc-opt input { width: 18px; height: 18px; margin: 9px 0 0; accent-color: var(--primary); }
.nc-opt input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.nc-opt-ic {
  display: grid; place-items: center;
  width: 36px; height: 36px;
  border-radius: var(--r-sm);
  background: var(--paper-2);
  color: var(--ink-2);
}
.nc-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.nc-opt:has(input:checked) .nc-opt-ic { background: var(--primary); color: var(--primary-ink); }
.nc-opt-text { display: grid; gap: 2px; min-width: 0; }
.nc-opt-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; font-weight: 600; color: var(--ink); }
.nc-opt-note { font-size: var(--fs-sm); color: var(--ink-2); }
.nc-rec { font-size: 11px; }
@media (max-width: 399.98px) {
  .nc-opt { grid-template-columns: auto minmax(0, 1fr); }
  .nc-opt-ic { display: none; }
}
