/* ============================================================
   Resume Builder — style.css
   Editorial "hiring desk" identity. No external fonts/CDNs.
   ============================================================ */

/* ---- Tokens ---- */
:root {
  /* warm-biased neutrals = chosen paper stock, not default grey */
  --paper:      #f4f2ec;   /* app ground */
  --surface:    #ffffff;   /* cards */
  --surface-2:  #faf9f5;   /* insets */
  --line:       #e2ddd2;   /* hairlines */
  --line-soft:  #ece8de;
  --ink:        #1b2434;   /* primary text */
  --ink-soft:   #55606f;   /* secondary text */
  --ink-mute:   #8b93a1;   /* placeholders / captions */
  --brand:      #274060;   /* app accent (deep slate blue) */
  --brand-ink:  #1c3049;
  --focus:      #3b6ea5;

  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, "Times New Roman", serif;

  --shadow-card: 0 1px 2px rgba(27,36,52,.05), 0 6px 20px rgba(27,36,52,.06);
  --shadow-paper: 0 2px 6px rgba(27,36,52,.08), 0 24px 60px rgba(27,36,52,.14);
  --radius: 12px;

  /* resume accent — user selectable */
  --accent: #274060;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #14161b;
    --surface:   #1c2028;
    --surface-2: #23272f;
    --line:      #333944;
    --line-soft: #2a2f38;
    --ink:       #e9ecf1;
    --ink-soft:  #aab2bf;
    --ink-mute:  #737c8a;
    --brand:     #7ea7d8;
    --brand-ink: #9cbde6;
    --focus:     #7ea7d8;
    --shadow-card: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px rgba(0,0,0,.35);
    --shadow-paper: 0 2px 6px rgba(0,0,0,.4), 0 30px 70px rgba(0,0,0,.5);
  }
}
/* explicit toggle wins both directions */
:root[data-theme="light"] {
  --paper:#f4f2ec; --surface:#fff; --surface-2:#faf9f5; --line:#e2ddd2; --line-soft:#ece8de;
  --ink:#1b2434; --ink-soft:#55606f; --ink-mute:#8b93a1; --brand:#274060; --brand-ink:#1c3049; --focus:#3b6ea5;
  --shadow-card:0 1px 2px rgba(27,36,52,.05),0 6px 20px rgba(27,36,52,.06);
  --shadow-paper:0 2px 6px rgba(27,36,52,.08),0 24px 60px rgba(27,36,52,.14);
}
:root[data-theme="dark"] {
  --paper:#14161b; --surface:#1c2028; --surface-2:#23272f; --line:#333944; --line-soft:#2a2f38;
  --ink:#e9ecf1; --ink-soft:#aab2bf; --ink-mute:#737c8a; --brand:#7ea7d8; --brand-ink:#9cbde6; --focus:#7ea7d8;
  --shadow-card:0 1px 2px rgba(0,0,0,.3),0 8px 24px rgba(0,0,0,.35);
  --shadow-paper:0 2px 6px rgba(0,0,0,.4),0 30px 70px rgba(0,0,0,.5);
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* theme icon visibility — show the icon for the theme you'd switch TO */
.i-sun  { display: inline; }
.i-moon { display: none; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .i-sun  { display: none; }
  :root:not([data-theme="light"]) .i-moon { display: inline; }
}
:root[data-theme="dark"]  .i-sun  { display: none; }
:root[data-theme="dark"]  .i-moon { display: inline; }
:root[data-theme="light"] .i-sun  { display: inline; }
:root[data-theme="light"] .i-moon { display: none; }

/* ============ Top bar ============ */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 40px);
  background: color-mix(in srgb, var(--paper) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { color: var(--brand); display: grid; place-items: center; }
.brand-text h1 {
  font-family: var(--font-serif);
  font-size: 21px;
  font-weight: 600;
  letter-spacing: .1px;
  margin: 0;
  line-height: 1.1;
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  letter-spacing: .3px;
  color: var(--ink-mute);
}

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* segmented template control */
.seg {
  display: inline-flex;
  padding: 3px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.seg-btn {
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 6px 14px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.seg-btn[aria-pressed="true"] {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(27,36,52,.12);
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 10px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.icon-btn:hover { color: var(--ink); border-color: var(--ink-mute); }

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 9px 16px;
  border: 1px solid var(--brand);
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  transition: filter .15s, transform .05s;
}
:root[data-theme="dark"] .btn-primary { color: #10151d; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: #10151d; } }
.btn-primary:hover { filter: brightness(1.07); }
.btn-primary:active { transform: translateY(1px); }

/* ============ Workspace ============ */
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: clamp(18px, 3vw, 40px);
  align-items: start;
  max-width: 1440px;
  margin: 0 auto;
  padding: clamp(18px, 3vw, 36px) clamp(16px, 4vw, 40px) 60px;
}

/* ---- Editor ---- */
.editor { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.save-note {
  font-size: 12.5px;
  color: var(--ink-mute);
  display: flex;
  align-items: center;
  gap: 7px;
  padding-left: 2px;
}
.save-note::before {
  content: "";
  width: 7px; height: 7px; border-radius: 50%;
  background: #3f9d6a;
  box-shadow: 0 0 0 3px color-mix(in srgb, #3f9d6a 22%, transparent);
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  padding: 18px 18px 20px;
  margin: 0;
  min-width: 0;
}
.card legend {
  font-family: var(--font-serif);
  font-size: 15.5px;
  font-weight: 600;
  color: var(--ink);
  padding: 0 8px;
  margin-left: -4px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--ink-soft);
}
.field-hint { text-transform: none !important; letter-spacing: 0 !important; font-weight: 500 !important; color: var(--ink-mute) !important; }

input, textarea {
  font: inherit;
  font-size: 14px;
  width: 100%;
  padding: 9px 11px;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
textarea { resize: vertical; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--ink-mute); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--focus);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 22%, transparent);
}

/* repeatable rows */
.repeat-list { display: flex; flex-direction: column; gap: 14px; margin-bottom: 14px; }
.repeat-item {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 14px;
  position: relative;
}
.repeat-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.repeat-head .ri-label {
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .6px;
  text-transform: uppercase;
  color: var(--ink-mute);
}
.ri-remove {
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 4px 9px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ri-remove:hover { color: #b23b47; border-color: #d99aa1; }
.ri-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.ri-grid .span-2 { grid-column: 1 / -1; }
.ri-dates { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.btn-add {
  font: inherit;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--brand);
  background: transparent;
  border: 1.5px dashed var(--line);
  border-radius: 9px;
  padding: 10px;
  width: 100%;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.btn-add:hover { border-color: var(--brand); background: color-mix(in srgb, var(--brand) 6%, transparent); }

/* swatches */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch {
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
  transition: transform .1s, box-shadow .15s;
}
.swatch:hover { transform: scale(1.08); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--ink); }

.editor-actions { display: flex; justify-content: flex-end; }
.btn-ghost {
  font: inherit;
  font-size: 13px;
  color: var(--ink-soft);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 8px 16px;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: #b23b47; border-color: #d99aa1; }

/* ---- Preview ---- */
.preview-wrap { position: sticky; top: 84px; min-width: 0; }
.preview-scale {
  background:
    repeating-linear-gradient(45deg, transparent 0 10px, color-mix(in srgb, var(--ink) 3%, transparent) 10px 11px);
  border-radius: 14px;
  padding: clamp(10px, 2vw, 22px);
  display: flex;
  justify-content: center;
  max-height: calc(100vh - 108px);
  overflow: auto;
}

/* ============================================================
   THE RESUME (paper) — always light, print-accurate.
   Base tokens fixed here so preview & print match exactly.
   ============================================================ */
.resume {
  --r-ink: #1f2937;
  --r-soft: #4b5563;
  --r-mute: #9ca3af;
  --r-line: #d7dce3;
  --r-ph: #b6bcc6;

  position: relative;
  width: 100%;
  max-width: 8.5in;
  background: #fff;
  color: var(--r-ink);
  box-shadow: var(--shadow-paper);
  padding: 0.62in 0.66in;
  border-radius: 3px;
  overflow: hidden;      /* contains the min-height float + clips corners */
  font-size: 10.4pt;
  line-height: 1.42;
}
/* reserves a letter-page MINIMUM height for the empty look;
   the paper still grows with content instead of clipping it */
.resume::before {
  content: "";
  float: left;
  width: 0;
  /* reserve a true US-Letter page for the empty look:
     (11in - 2*0.62in vertical padding) / (8.5in - 2*0.66in content width) ≈ 1.36 */
  padding-top: 136%;
}
/* placeholder text inside preview */
.rp-ph { color: var(--r-ph); font-style: italic; }

.resume .r-empty { color: var(--r-mute); font-style: italic; }

.r-section { margin-top: 15px; }
.r-section:first-child { margin-top: 0; }
.r-items { display: flex; flex-direction: column; gap: 11px; }
.r-item .r-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.r-item .r-role { font-weight: 700; }
.r-item .r-org { color: var(--r-soft); }
.r-item .r-dates { color: var(--r-mute); font-size: 9pt; white-space: nowrap; font-variant-numeric: tabular-nums; }
.r-bullets { margin: 5px 0 0; padding-left: 16px; }
.r-bullets li { margin: 2px 0; }
.r-detail { margin-top: 3px; color: var(--r-soft); }

/* ---- Header (name block) ---- */
.r-name { font-weight: 700; letter-spacing: .2px; line-height: 1.05; }
.r-headline { color: var(--r-soft); }
.r-contact { color: var(--r-soft); font-size: 9pt; }
.r-contact span:not(:last-child)::after { content: "  ·  "; color: var(--r-mute); }

/* skills */
.r-skills { display: flex; flex-wrap: wrap; gap: 6px 7px; }
.r-chip {
  border: 1px solid var(--r-line);
  border-radius: 20px;
  padding: 2px 10px;
  font-size: 9pt;
  color: var(--r-soft);
}

/* ============ Template: MODERN (sans, left, colored rules) ============ */
.tpl-modern { font-family: var(--font-ui); }
.tpl-modern .r-name { font-size: 22pt; color: var(--accent); }
.tpl-modern .r-headline { margin-top: 1px; text-transform: uppercase; letter-spacing: 1.4px; font-weight: 600; font-size: 9.5pt; color: var(--r-soft); }
.tpl-modern .r-head { padding-bottom: 10px; border-bottom: 2px solid var(--accent); }
.tpl-modern .r-contact { margin-top: 7px; }
.tpl-modern .r-title {
  font-size: 10.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.3px;
  color: var(--accent);
  margin-bottom: 8px;
  padding-bottom: 3px;
  border-bottom: 1px solid var(--r-line);
}
.tpl-modern .r-bullets li::marker { color: var(--accent); }

/* ============ Template: CLASSIC (serif, centered head, ruled) ============ */
.tpl-classic { font-family: var(--font-serif); }
.tpl-classic .r-head { text-align: center; padding-bottom: 10px; border-bottom: 1.5px solid var(--accent); }
.tpl-classic .r-name { font-size: 23pt; letter-spacing: 1.5px; color: var(--accent); }
.tpl-classic .r-headline { font-size: 12pt; font-style: italic; margin-top: 2px; }
.tpl-classic .r-contact { margin-top: 6px; }
.tpl-classic .r-title {
  font-size: 11.5pt;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 2.4px;
  text-align: center;
  color: var(--r-ink);
  margin-bottom: 9px;
  position: relative;
}
.tpl-classic .r-title::after {
  content: "";
  display: block;
  height: 1px;
  background: color-mix(in srgb, var(--accent) 45%, var(--r-line));
  margin-top: 5px;
}
.tpl-classic .r-bullets { padding-left: 18px; }

/* ============ Responsive ============ */
@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-wrap { position: static; order: -1; }
  .preview-scale { max-height: none; }
  .resume { max-width: 100%; }
}
@media (max-width: 560px) {
  .grid-2, .ri-grid { grid-template-columns: 1fr; }
  .brand-text p { display: none; }
  .toolbar { width: 100%; justify-content: space-between; }
  .btn-primary span { display: none; }
}

/* ============ SEO prose ============ */
.prose {
  max-width: 760px;
  margin: 10px auto 0;
  padding: 40px clamp(16px, 4vw, 40px) 10px;
  border-top: 1px solid var(--line);
}
.prose h2 { font-family: var(--font-serif); font-size: 24px; margin: 0 0 14px; text-wrap: balance; }
.prose h3 { font-family: var(--font-serif); font-size: 19px; margin: 34px 0 14px; }
.prose p { color: var(--ink-soft); max-width: 68ch; }
.faq { display: flex; flex-direction: column; gap: 10px; }
.faq details {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 4px 16px;
}
.faq summary {
  font-weight: 600;
  cursor: pointer;
  padding: 12px 0;
  list-style: none;
  position: relative;
  padding-right: 26px;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 2px; top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  color: var(--ink-mute);
  font-weight: 400;
}
.faq details[open] summary::after { content: "\2013"; }
.faq details[open] summary { border-bottom: 1px solid var(--line-soft); }
.faq p { margin: 12px 0; font-size: 14.5px; }

.site-footer {
  text-align: center;
  padding: 30px 20px 44px;
  color: var(--ink-mute);
  font-size: 13px;
}
.site-footer a { color: var(--brand); text-decoration: none; }
.site-footer a:hover { text-decoration: underline; }

/* keyboard focus */
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

/* ============================================================
   PRINT — only the resume paper prints
   ============================================================ */
@page { size: letter; margin: 0.5in; }

@media print {
  :root { --shadow-paper: none; }
  body { background: #fff; }
  .topbar, .editor, .prose, .site-footer { display: none !important; }
  .workspace { display: block; margin: 0; padding: 0; max-width: none; }
  .preview-wrap { position: static; }
  .preview-scale {
    background: none;
    padding: 0;
    max-height: none;
    overflow: visible;
    display: block;
  }
  .resume {
    box-shadow: none;
    border-radius: 0;
    max-width: none;
    width: 100%;
    overflow: visible;
    padding: 0;
    font-size: 10.5pt;
    color: #000 !important;
  }
  .resume::before { content: none; }
  .resume, .resume * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .r-item, .r-section { break-inside: avoid; }
}
