/* ==========================================================================
   Yana Rulinsky — portfolio
   One stylesheet, no build step. Colours are the supplied brand tokens only.
   Contrast (measured against --page #FEFAF4 unless noted):
     --ink   #1A1A1A on --page   16.7:1   body text
     --navy  #1F3B5C on --page   11.0:1   headings, nav, footer
     --link  #205E96 on --page    6.5:1   links (always underlined)
     --btn   #2C72B2 + #fff       5.05:1  buttons
     --muted #5A5A5A on --page    6.6:1   captions (NEVER on --soft: 3.6:1 fails)
     #fff  on --navy             ~11.5:1  text on dark bands
     #B9DAEF on --navy            ~7.8:1  headings/links on dark bands
     --link  on --soft #B9DAEF    4.62:1  lightest allowed on the soft panel
   --brand #3384CF is decoration only (rules, borders, icons): 3:1 non-text.
   ========================================================================== */

:root {
  --page:  #FEFAF4;
  --ink:   #1A1A1A;
  --navy:  #1F3B5C;
  --link:  #205E96;
  --btn:   #2C72B2;
  --brand: #3384CF;
  --soft:  #B9DAEF;
  --muted: #5A5A5A;
  --focus: #1F3B5C;

  --font-sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

  --maxw: 1120px;
  --reading: 68ch;
  --pad: clamp(1rem, 4vw, 2rem);

  --radius: 10px;
  --shadow: 0 1px 3px rgba(31, 59, 92, .10), 0 6px 20px rgba(31, 59, 92, .06);
}

/* ---------- reset-ish ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 6.5rem; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 1.0625rem;      /* 17px */
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; height: auto; display: block; }

/* In-page anchors must clear the sticky header (header height + ~1rem).
   scroll-padding-top on <html> (above) is the reliable offset for fragment
   jumps in Chrome; scroll-margin-top on the target is the fallback. On narrow
   screens the header wraps to a taller two-row layout (~118px), so both values
   are raised there to keep the landing heading fully visible. */
[id] { scroll-margin-top: 6.5rem; }
@media (max-width: 820px) {
  html { scroll-padding-top: 8.5rem; }
  [id]  { scroll-margin-top: 8.5rem; }
}

h1, h2, h3, h4 {
  color: var(--navy);
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 .5em;
  font-weight: 700;
}
h1 { font-size: clamp(2rem, 5vw, 3rem); }
h2 { font-size: clamp(1.5rem, 3.5vw, 2.125rem); }
h3 { font-size: clamp(1.2rem, 2.4vw, 1.4rem); }
h4 { font-size: 1.05rem; text-transform: none; }

p { margin: 0 0 1.1rem; }
ul, ol { margin: 0 0 1.1rem; padding-left: 1.4rem; }
li { margin: .35rem 0; }

a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-thickness: 1px;
}
a:hover { color: var(--navy); text-decoration-thickness: 2px; }

strong { font-weight: 700; }
abbr[title] { text-decoration: none; }

/* ---------- focus: always visible, never removed ---------- */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 2px;
}
/* On dark bands the navy ring would vanish — switch to a light ring (>=3:1 on navy). */
.band--navy :focus-visible,
.site-footer :focus-visible { outline-color: var(--soft); }

/* ---------- skip link ---------- */
.skip-link {
  position: absolute;
  left: 8px;
  top: -60px;
  z-index: 1000;
  background: var(--navy);
  color: #fff;
  padding: .6rem 1rem;
  border-radius: 0 0 var(--radius) var(--radius);
  text-decoration: underline;
  transition: top .15s ease;
}
.skip-link:focus { top: 0; color: #fff; }

/* ---------- layout helpers ---------- */
.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: var(--pad); }

.band { padding-block: clamp(2.5rem, 7vw, 5rem); }
.band + .band { padding-top: clamp(2.5rem, 7vw, 5rem); }
.band--navy { background: var(--navy); color: #fff; }
.band--navy h1, .band--navy h2, .band--navy h3 { color: #fff; }
.band--soft { background: var(--soft); color: var(--ink); }
.band--soft h1, .band--soft h2, .band--soft h3 { color: var(--navy); }
.band--soft a { color: var(--link); }              /* 4.62:1 on soft */
.band--soft a:hover { color: var(--navy); }

.band--navy a { color: #fff; text-decoration-thickness: 2px; }
.band--navy a:hover { color: var(--soft); }

.prose { max-width: var(--reading); }
.prose > :last-child { margin-bottom: 0; }

.lede { font-size: 1.2rem; color: var(--ink); }
.band--navy .lede { color: #fff; }

.muted { color: var(--muted); font-size: .95rem; }

.center { text-align: center; }
.stack > * + * { margin-top: 1.1rem; }

/* ---------- header ---------- */
.site-header {
  background: var(--page);
  border-bottom: 2px solid var(--brand);   /* decorative rule */
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .75rem 1.25rem;
  padding-block: .6rem;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; text-decoration: none; flex: 0 0 auto; }
.brand:hover { text-decoration: none; }
.brand img { width: 56px; height: 56px; border-radius: 50%; }
.brand span {
  font-weight: 700;
  color: var(--navy);
  font-size: 1.05rem;
  letter-spacing: -0.01em;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  font: inherit;
  font-weight: 600;
  color: var(--navy);
  background: transparent;
  border: 2px solid var(--brand);
  border-radius: 8px;
  padding: .4rem .8rem;
  cursor: pointer;
}
.nav-toggle:hover { background: var(--soft); }

.primary-nav { flex: 1 1 auto; }
.primary-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: .25rem 1.1rem;
  align-items: center;
}
.primary-nav a {
  display: inline-block;
  color: var(--navy);
  text-decoration: none;
  font-weight: 600;
  padding: .5rem .25rem;
  border-bottom: 3px solid transparent;
}
.primary-nav a:hover { border-bottom-color: var(--brand); color: var(--navy); }
.primary-nav a[aria-current="page"] {
  border-bottom-color: var(--navy);   /* non-colour cue for current page */
}

.header-actions {
  display: flex;
  gap: .5rem .9rem;
  align-items: center;
  flex: 0 0 auto;
  flex-wrap: wrap;
}
.header-actions a {
  text-decoration: none;
  font-weight: 600;
  color: var(--link);
  display: inline-flex;
  align-items: center;
  gap: .35rem;
}
.header-actions a:hover { color: var(--navy); text-decoration: underline; }
.header-actions svg { width: 20px; height: 20px; fill: var(--brand); flex: 0 0 auto; }

@media (max-width: 820px) {
  .nav-toggle { display: inline-block; }
  .primary-nav { flex-basis: 100%; order: 3; }
  .primary-nav[hidden] { display: none; }
  .primary-nav ul { flex-direction: column; align-items: stretch; gap: 0; }
  .primary-nav li { margin: 0; border-top: 1px solid var(--soft); }
  .primary-nav a { display: block; padding: .8rem .25rem; border-bottom: 0; border-left: 3px solid transparent; }
  .primary-nav a[aria-current="page"] { border-bottom: 0; border-left-color: var(--navy); background: rgba(185, 218, 239, .35); }
  .header-actions { order: 2; margin-left: auto; }
}

/* ---------- buttons ---------- */
.btn {
  display: inline-block;
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  padding: .7rem 1.3rem;
  border-radius: 8px;
  border: 2px solid var(--btn);
  cursor: pointer;
}
.btn--primary { background: var(--btn); color: #fff; }
.btn--primary:hover { background: var(--navy); border-color: var(--navy); color: #fff; text-decoration: none; }
.btn--ghost { background: transparent; color: var(--link); }
.btn--ghost:hover { background: var(--btn); border-color: var(--btn); color: #fff; text-decoration: none; }
.band--navy .btn--primary { background: #fff; color: var(--navy); border-color: #fff; }
.band--navy .btn--primary:hover { background: var(--soft); border-color: var(--soft); color: var(--navy); }
.band--navy .btn--ghost { color: #fff; border-color: #fff; }
.band--navy .btn--ghost:hover { background: #fff; color: var(--navy); }
.btn-row { display: flex; flex-wrap: wrap; gap: .8rem 1rem; margin-top: 1.4rem; }

/* ---------- hero ---------- */
.hero { display: grid; gap: clamp(1.5rem, 5vw, 3rem); align-items: center; }
@media (min-width: 780px) { .hero { grid-template-columns: 1.3fr .9fr; } }
.hero h1 { margin-bottom: .3em; }
.hero .subhead { font-size: 1.2rem; color: var(--ink); max-width: 46ch; }

/* headshot: rounded-corner with an offset soft panel behind (no crop) */
.portrait { position: relative; max-width: 450px; margin-inline: auto; }
.portrait::before {
  content: "";
  position: absolute;
  inset: 18px -18px -18px 18px;
  background: var(--soft);
  border-radius: var(--radius);
  z-index: 0;
}
.portrait img { position: relative; z-index: 1; border-radius: var(--radius); width: 100%; box-shadow: var(--shadow); }
.about-portrait { float: none; max-width: 400px; margin: 0 0 1.5rem; }
@media (min-width: 720px) {
  .about-lead { display: grid; grid-template-columns: 1fr 400px; gap: 2rem; align-items: start; }
  .about-portrait { margin-top: .4rem; }
}

/* ---------- cards ---------- */
.card-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr));
}
/* "How I work" — always three across on wide screens, so six boxes read 3 and 3. */
@media (min-width: 900px) {
  .card-grid--three { grid-template-columns: repeat(3, 1fr); }
}
.card {
  background: var(--page);
  color: var(--ink);
  border: 1px solid rgba(31, 59, 92, .18);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius);
  padding: 1.4rem 1.4rem 1.5rem;
  box-shadow: var(--shadow);
}
.card h3 { margin-top: 0; }
.card h3 a { text-decoration: none; color: var(--navy); }
.card h3 a:hover { text-decoration: underline; }
.card > :last-child { margin-bottom: 0; }
.band--navy .card { background: var(--page); color: var(--ink); }
.band--navy .card h3 { color: var(--navy); }
.band--navy .card a { color: var(--link); text-decoration: underline; }
.band--navy .card a:hover { color: var(--navy); }
.band--soft .card { background: #fff; }

/* ---------- case study layout ---------- */
/* Each study sits in its own full-bleed band. The alternating band colour is the only
   separator between studies — no borders, cards, or drop shadows. The text column is
   left-aligned so its left edge lines up with every other page. */
.cs-band--cream { background: var(--page); }
.cs-band--white { background: #fff; }
/* a full-bleed coloured separator between consecutive studies */
.cs-band + .cs-band { border-top: 8px solid var(--brand); }
.cs { max-width: var(--reading); }
.cs h2 { margin-bottom: .25em; }
.cs .dek { color: var(--muted); font-style: italic; font-size: 1.05rem; margin-bottom: 1.4rem; }
.cs h3 { margin-top: 1.8rem; }
.cs .role { background: var(--soft); color: var(--ink); border-radius: var(--radius); padding: 1rem 1.2rem; margin: 1.2rem 0; }
.cs .role p:last-child { margin-bottom: 0; }

/* before / after screenshots (Case Study 8) */
.beforeafter { margin: 1.8rem 0; }
.beforeafter figure { margin: 0 0 1.6rem; }
.beforeafter figure:last-child { margin-bottom: 0; }
.beforeafter h4 { margin: 0 0 .6rem; }
.screens-gallery--pair { grid-template-columns: repeat(auto-fit, minmax(110px, 190px)); justify-content: start; }

.artifacts { background: var(--soft); color: var(--ink); border-radius: var(--radius); padding: 1.2rem 1.4rem; margin-top: 1.8rem; }
.artifacts h3 { margin: 0 0 .6rem; color: var(--navy); font-size: 1.1rem; }
.artifacts ul { list-style: none; padding: 0; margin: 0; }
.artifacts li { margin: .5rem 0; padding-left: 1.4rem; position: relative; }
.artifacts li::before {
  content: "";
  position: absolute; left: 0; top: .55em;
  width: .5rem; height: .5rem;
  background: var(--brand);
  border-radius: 2px;
}
.artifacts a { color: var(--link); }
.artifacts a:hover { color: var(--navy); }
.artifacts .note { color: var(--ink); font-size: .95rem; margin: .8rem 0 0; }

/* ---------- results table (Case Study 2) ---------- */
.table-scroll {
  overflow-x: auto;
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  margin: 1.4rem 0;
}
.table-scroll:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
table { border-collapse: collapse; width: 100%; min-width: 34rem; }
caption { text-align: left; padding: .8rem 1rem; color: var(--muted); font-size: .95rem; }
th, td { padding: .6rem .9rem; text-align: left; border-bottom: 1px solid rgba(31, 59, 92, .18); }
thead th { background: var(--navy); color: #fff; border-bottom: 0; }
tbody tr:nth-child(even) { background: rgba(185, 218, 239, .28); }
tbody th { font-weight: 600; }

/* ---------- media / video ---------- */
.media-figure { margin: 1.6rem 0; }
.video-embed {
  position: relative;
  aspect-ratio: 16 / 9;
  background: var(--navy);
  border-radius: var(--radius);
  overflow: hidden;
  border: 1px solid var(--brand);
}
.video-embed iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
figcaption { color: var(--muted); font-size: .95rem; margin-top: .5rem; }
.band--navy figcaption { color: var(--soft); }

.video-placeholder {
  aspect-ratio: 16 / 9;
  display: grid;
  place-content: center;
  text-align: center;
  gap: .5rem;
  padding: 1.5rem;
  background: var(--soft);
  color: var(--ink);
  border: 2px dashed var(--brand);
  border-radius: var(--radius);
}

/* ---------- lab ---------- */
.lab-featured { display: grid; gap: 2rem; align-items: start; }
@media (min-width: 820px) { .lab-featured { grid-template-columns: 360px 1fr; } }
.lab-featured img { border-radius: var(--radius); box-shadow: var(--shadow); }
.lab-entry { padding-block: 1.6rem; border-top: 1px solid var(--brand); max-width: var(--reading); }

/* click-to-load Scratch facade */
.scratch-facade {
  position: relative;
  aspect-ratio: 485 / 402;
  max-width: 100%;              /* fill the entry, matching the other video figures */
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--navy);
}
.scratch-facade > img { width: 100%; height: 100%; object-fit: cover; }
.scratch-facade iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.scratch-play {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: .5rem;
  width: 100%;
  font: inherit; font-weight: 700; font-size: 1.05rem;
  color: #fff;
  background: rgba(23, 42, 66, .74);
  border: 0;
  cursor: pointer;
  text-align: center;
  padding: 1rem;
  text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
}
.scratch-play:hover { background: rgba(23, 42, 66, .82); }
.scratch-play:focus-visible { outline: 4px solid #fff; outline-offset: -6px; }
.scratch-play__icon {
  display: grid; place-content: center;
  width: 3.2rem; height: 3.2rem;
  border-radius: 50%;
  background: #fff; color: var(--navy);
  font-size: 1.3rem;
}
.lab-entry h3 { margin-bottom: .3rem; }
.lab-entry .tools { color: var(--muted); font-size: .9rem; text-transform: uppercase; letter-spacing: .04em; margin-bottom: .6rem; }

.screens-gallery {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  margin: 1.4rem 0;
}
.screens-gallery img { border: 1px solid var(--brand); border-radius: 8px; margin-inline: auto; }

/* ---------- writing ---------- */
.post-list { list-style: none; padding: 0; margin: 0; max-width: var(--reading); }
.post-list li { border-top: 1px solid var(--brand); padding: 1.4rem 0; margin: 0; }
.post-list li:first-child { border-top: 0; }
.post-list h2 { font-size: 1.3rem; margin-bottom: .3rem; }
.post-list h2 a { text-decoration: none; }
.post-list h2 a:hover { text-decoration: underline; }
.post-list time { display: block; color: var(--muted); font-size: .9rem; margin-bottom: .4rem; }

.post-body { max-width: var(--reading); }
.post-body h2 { margin-top: 2rem; }
.post-body time { color: var(--muted); }
.post-body blockquote {
  margin: 1.4rem 0;
  padding: .6rem 0 .6rem 1.2rem;
  border-left: 4px solid var(--brand);
  color: var(--ink);
}
.post-body .references { margin-top: 2.5rem; padding-top: 1.2rem; border-top: 1px solid var(--brand); }
.post-body .references h2 { font-size: 1.2rem; }
.post-body .references p { font-size: .95rem; color: var(--ink); padding-left: 2rem; text-indent: -2rem; }

/* ---------- contact form ---------- */
.contact-grid { display: grid; gap: 2.5rem; }
@media (min-width: 820px) { .contact-grid { grid-template-columns: 1fr 1fr; } }
.contact-details { list-style: none; padding: 0; margin: 0; }
.contact-details li { margin: .8rem 0; padding-left: 0; }
.contact-details strong { display: block; color: var(--navy); }

form.contact { max-width: 34rem; }
.field { margin-bottom: 1.2rem; }
.field label { display: block; font-weight: 600; color: var(--navy); margin-bottom: .3rem; }
.field .hint { display: block; color: var(--muted); font-size: .9rem; margin-bottom: .35rem; }
.field input, .field textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--navy);
  border-radius: 8px;
  padding: .6rem .7rem;
}
.field textarea { min-height: 9rem; resize: vertical; }
.field input:focus-visible, .field textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.field [aria-invalid="true"] { border-color: #a01b1b; }
.field .error {
  display: block;
  margin-top: .35rem;
  color: #a01b1b;         /* #A01B1B on --page ~ 7.0:1 */
  font-weight: 600;
  font-size: .95rem;
}
.field .error::before { content: "⚠ "; }
.field .error:empty { display: none; }

.form-status {
  margin: 1rem 0;
  padding: 1rem 1.2rem;
  border-radius: var(--radius);
  border: 2px solid var(--brand);
  background: var(--soft);
  color: var(--ink);
  font-weight: 600;
}
.form-status:empty { display: none; }
.form-status.is-error { border-color: #a01b1b; background: #fbeaea; }

.hp-field { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }

/* ---------- footer ---------- */
.site-footer {
  background: var(--navy);
  color: #fff;
  padding-block: 1.6rem;
  margin-top: 0;
  text-align: center;
}
.site-footer p { margin: 0; font-size: .95rem; }

/* ---------- utilities ---------- */
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap; border: 0;
}
.new-tab-note::after { content: " (opens in a new tab)"; }

[hidden] { display: none !important; }
