/* ==========================================================================
   Artem Efremenko — portfolio styles
   One stylesheet for the whole site. Written mobile-first: the base rules are
   for phones, and the @media blocks further down add the wider layouts.

   Contents
   1. Settings (colours, spacing, fonts) — change the look here
   2. Base elements
   3. Layout helpers
   4. Header and footer
   5. Home
   6. Photography gallery + lightbox
   7. Transport design cases
   8. About
   9. Contact
   10. Small extras (reveal animation, TODO marks)
   ========================================================================== */


/* 1. Settings ------------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --text: #161616;
  --muted: #6a6a6a;      /* secondary text; 5.4:1 contrast on white */
  --line: #e6e6e6;       /* hairlines */

  --gutter: clamp(1rem, 4vw, 3rem);   /* space at the page edges */
  --gap: clamp(1rem, 2.5vw, 2rem);    /* space between images */
  --section: clamp(3.5rem, 9vw, 7rem);/* vertical space between sections */

  --width: 1100px;       /* text pages */
  --width-wide: 1500px;  /* gallery */
  --measure: 36rem;      /* comfortable line length for paragraphs */

  /* Uses Inter if the visitor has it, otherwise the system grotesk.
     No font files are downloaded. See README to self-host a font. */
  --font: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif;
}


/* 2. Base elements -------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

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

h1, h2 { font-weight: 500; line-height: 1.15; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(1.9rem, 5vw, 3rem); }
h2 { font-size: clamp(1.4rem, 3vw, 1.9rem); }

p { margin: 0 0 1.1em; }
ul { margin: 0; padding: 0; list-style: none; }
figure { margin: 0; }

a { color: inherit; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
a:hover { text-decoration-thickness: 2px; }

/* Visible keyboard focus everywhere */
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

.skip-link { position: absolute; left: -999px; top: 0; background: var(--text); color: var(--bg); padding: 0.5rem 1rem; z-index: 10; }
.skip-link:focus { left: 0; }


/* 3. Layout helpers ------------------------------------------------------- */

.wrap, .wrap-wide { margin-inline: auto; padding-inline: var(--gutter); }
.wrap { max-width: calc(var(--width) + 2 * var(--gutter)); }
.wrap-wide { max-width: calc(var(--width-wide) + 2 * var(--gutter)); }

.muted { color: var(--muted); }
.lead { font-size: clamp(1.2rem, 2.6vw, 1.5rem); line-height: 1.4; max-width: 30em; }

.page-head { padding-block: clamp(2rem, 6vw, 4.5rem) clamp(2rem, 5vw, 3.5rem); }
.page-head h1 { margin-bottom: 0.6em; }
.page-head p { max-width: var(--measure); }
.page-head .lead { max-width: 40em; text-wrap: balance; }   /* one line on a wide screen */


/* 4. Header and footer ---------------------------------------------------- */

.site-header {
  display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between;
  gap: 0.4rem 2rem;
  padding: 1.1rem var(--gutter);
}
.site-name { font-weight: 500; text-decoration: none; }
.site-header ul { display: flex; flex-wrap: wrap; gap: 0.2rem 1.3rem; }
.site-header nav a { color: var(--muted); text-decoration: none; padding-block: 0.35rem; display: inline-block; }
.site-header nav a:hover,
.site-header nav a[aria-current="page"] { color: var(--text); }
.site-header nav a[aria-current="page"] { text-decoration: underline; }

/* Keep the four links on one line on a phone */
@media (max-width: 480px) {
  .site-header ul { gap: 0.2rem 0.8rem; }
  .site-header nav a { font-size: 0.85rem; }
}

.site-footer {
  display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0.5rem 2rem;
  margin-top: var(--section);
  padding: 1.5rem var(--gutter) 2.5rem;
  border-top: 1px solid var(--line);
  color: var(--muted); font-size: 0.9rem;
}
.site-footer p { margin: 0; }
.site-footer ul { display: flex; gap: 1.3rem; }


/* 5. Home ----------------------------------------------------------------- */

/* Full-bleed intro video with the title on top. The clip is cropped
   (object-fit: cover) to fill the screen, so its edges may be cut. */
.hero {
  position: relative;
  height: calc(100svh - 4rem);         /* the screen minus the header */
  min-height: 420px; max-height: 1100px;
  background: #1c1c1c;                 /* dark while the poster loads, so the text stays readable */
  overflow: hidden;
}
.hero-media {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover;
  background: none;
}
/* Dark gradient behind the text. White text over it stays above the 4.5 : 1
   contrast minimum even when the clip is bright (snow, white trains, sky). */
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(to top,
    rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.64) 32%, rgba(0, 0, 0, 0) 66%);
}
.hero-text {
  position: absolute; z-index: 1; left: 0; right: 0; bottom: 0;
  display: block; padding: 0 var(--gutter) clamp(2rem, 6vw, 4.5rem);
  color: #fff; text-decoration: none;
  text-shadow: 0 1px 16px rgba(0, 0, 0, 0.35);
}
.hero-title {
  display: block;
  font-size: clamp(2.6rem, 9vw, 6rem); font-weight: 500;
  line-height: 1; letter-spacing: -0.03em;
}
.hero-sub {
  display: block; max-width: 40em; margin-top: 0.8rem;
  text-wrap: balance;         /* if it must wrap, two even lines */
  font-size: clamp(1.05rem, 2.2vw, 1.45rem); line-height: 1.35;
}
.hero-text:hover .hero-title { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 0.12em; }
.hero-text:focus-visible { outline-color: #fff; outline-offset: -6px; }

.intro { padding-top: clamp(2rem, 5vw, 3.5rem); }
.intro h1 { margin-bottom: 0.5em; }
.intro .lead {
  margin-bottom: 0.5em;
  max-width: none;            /* one line on a wide screen */
  text-wrap: balance;         /* on narrower ones, lines of similar length */
}
.entry-links { display: flex; flex-wrap: wrap; gap: 0.5rem 2rem; margin-top: 2rem; }
.entry-links a::after { content: " →"; }


/* 6. Photography gallery + lightbox --------------------------------------- */

/* One column on phones; two columns from 700px. CSS columns let landscape
   and portrait photos sit together without any cropping. */
.gallery { column-gap: var(--gap); }
.gallery figure { break-inside: avoid; margin-bottom: calc(var(--gap) + 0.5rem); }
.gallery a { display: block; }
.gallery img { width: 100%; }
figcaption { margin-top: 0.5rem; color: var(--muted); font-size: 0.85rem; }

@media (min-width: 700px) {
  .gallery { columns: 2; }
}

/* Lightbox: the <dialog> is created by js/site.js when a photo is clicked. */
.lightbox {
  width: 100vw; height: 100vh; height: 100dvh; max-width: none; max-height: none;
  margin: 0; padding: 3.5rem 1rem 1rem; border: 0;
  background: var(--bg); color: var(--text);
}
.lightbox[open] { display: flex; align-items: center; justify-content: center; }
.lightbox::backdrop { background: var(--bg); }
.lightbox figure { display: flex; flex-direction: column; align-items: center; max-height: 100%; min-height: 0; }
.lightbox img { max-width: 100%; max-height: calc(100dvh - 8rem); width: auto; object-fit: contain; background: none; }
.lightbox button {
  position: absolute; border: 0; background: none; color: var(--text);
  font: inherit; font-size: 1.6rem; line-height: 1; padding: 0.8rem 1rem; cursor: pointer;
}
.lightbox .close { top: 0.3rem; right: 0.3rem; }
.lightbox .prev, .lightbox .next { top: 50%; transform: translateY(-50%); }
.lightbox .prev { left: 0; }
.lightbox .next { right: 0; }
@media (min-width: 700px) { .lightbox { padding-inline: 4.5rem; } }


/* 7. Transport design cases ---------------------------------------------- */

.toc { display: flex; flex-direction: column; gap: 0.3rem; margin-top: 2rem; }

.case { padding-top: var(--section); scroll-margin-top: -2rem; }
.case + .case { margin-top: 0; }
.case header { border-top: 1px solid var(--line); padding-top: 1.5rem; }
.case .meta { color: var(--muted); font-size: 0.95rem; margin: 0.6rem 0 1.5rem; }
.case-text { max-width: var(--measure); }

.case-images { display: grid; gap: var(--gap); margin-top: 2.5rem; }
.case-images img { width: 100%; }
@media (min-width: 700px) {
  .case-images { grid-template-columns: 1fr 1fr; }
  .case-images .wide { grid-column: 1 / -1; }
}


/* 8. About ---------------------------------------------------------------- */

.about { display: grid; gap: 2.5rem; padding-top: clamp(1.5rem, 5vw, 4rem); }
.about .portrait { width: 100%; max-width: 360px; }
.prose h1 { margin-bottom: 0.8em; }
.prose p { max-width: var(--measure); }
.prose .lead { margin-bottom: 1.5em; }

.facts { margin: 2.5rem 0; max-width: var(--measure); font-size: 0.95rem; }
.facts div { display: grid; grid-template-columns: 6.5rem 1fr; gap: 1rem; padding: 0.6rem 0; border-top: 1px solid var(--line); }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }

/* The small informal photo near the end of About */
.sidekick { width: 260px; max-width: 100%; margin: 0 0 2.5rem; }
.sidekick img { width: 100%; }

@media (min-width: 800px) {
  .about { grid-template-columns: 360px 1fr; gap: clamp(3rem, 7vw, 6rem); align-items: start; }
}


/* Media: screenshots of publications, three across on wide screens.
   A hairline frame keeps white web pages from melting into the white page. */
.media { padding-top: var(--section); }
.media h2 { margin-bottom: 0.4em; }
.media-grid { display: grid; gap: var(--gap); margin-top: 2rem; align-items: start; }
.media-grid img { width: 100%; border: 1px solid var(--line); }
@media (min-width: 900px) { .media-grid { grid-template-columns: repeat(3, 1fr); } }


/* 9. Contact -------------------------------------------------------------- */

.big-link { font-size: clamp(1.3rem, 4vw, 2rem); margin: 2.5rem 0; overflow-wrap: anywhere; }
.links { display: flex; flex-direction: column; gap: 0.4rem; }

/* Only used if you switch on the optional form in contact.html */
.contact-form { display: grid; gap: 0.4rem; max-width: var(--measure); }
.contact-form label { margin-top: 1rem; font-size: 0.9rem; color: var(--muted); }
.contact-form input, .contact-form textarea {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid #8a8a8a; border-radius: 2px; padding: 0.7rem 0.8rem; width: 100%;
}
.contact-form button {
  justify-self: start; margin-top: 1.5rem; padding: 0.7rem 1.6rem;
  font: inherit; color: var(--bg); background: var(--text); border: 0; border-radius: 2px; cursor: pointer;
}


/* 10. Small extras -------------------------------------------------------- */

/* Country flags on the photography page. They follow "Countries so far:" on
   the same line and wrap like words. The extra font only exists on Windows,
   where the flag polyfill adds it; elsewhere the system emoji font is used. */
.countries { max-width: var(--measure); color: var(--muted); }
.countries p, .flags { display: inline; }
.flags {
  margin: 0;
  font-family: "Twemoji Country Flags", var(--font);
  font-size: 1.15em; line-height: 1.9;
}
.flags li { display: inline-block; margin-right: 0.18em; cursor: default; }

/* Flags with photos are buttons that filter the gallery. */
.flags button {
  font: inherit; line-height: inherit; color: inherit;
  background: none; border: 0; padding: 0 0 0.15em; margin: 0;
  cursor: pointer; border-bottom: 2px solid transparent;
}
.flags.is-filtered li { opacity: 0.4; }
.flags.is-filtered li:has(button[aria-pressed="true"]) { opacity: 1; }
.flags button[aria-pressed="true"] { border-bottom-color: var(--text); }
.flags.is-filtered li:hover { opacity: 1; }

.filter-status { margin: 1.2rem 0 0; font-size: 0.95rem; color: var(--muted); }
.filter-status[hidden] { display: none; }
.filter-status .show-all {
  font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer;
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em;
}


/* Motion ------------------------------------------------------------------
   Everything below only runs for visitors who have not asked their system for
   reduced motion. All of it is slow and small on purpose. */

@media (prefers-reduced-motion: no-preference) {

  @keyframes rise   { from { opacity: 0; transform: translateY(14px); } }
  @keyframes settle { from { opacity: 0; transform: scale(1.03); } }
  @keyframes fade   { from { opacity: 0; } }

  /* Home: the intro video settles in, then the text rises line by line */
  .hero-media { animation: settle 1.6s cubic-bezier(.2, .7, .2, 1) both; }
  .hero-title { animation: rise 0.9s 0.3s cubic-bezier(.2, .7, .2, 1) both; }
  .hero-sub   { animation: rise 0.9s 0.45s cubic-bezier(.2, .7, .2, 1) both; }
  .intro > *, .page-head > *, .about > * {
    animation: rise 0.8s cubic-bezier(.2, .7, .2, 1) both;
  }
  .intro > :nth-child(1), .page-head > :nth-child(1) { animation-delay: 0.15s; }
  .intro > :nth-child(2), .page-head > :nth-child(2) { animation-delay: 0.25s; }
  .intro > :nth-child(3), .page-head > :nth-child(3) { animation-delay: 0.35s; }
  .intro > :nth-child(4), .page-head > :nth-child(4) { animation-delay: 0.45s; }
  .intro > :nth-child(n+5), .page-head > :nth-child(n+5) { animation-delay: 0.55s; }

  /* Flags appear one after another (js/site.js numbers them with --i) */
  .flags li {
    animation: rise 0.5s cubic-bezier(.2, .7, .2, 1) both;
    animation-delay: calc(0.5s + var(--i, 0) * 30ms);
    transition: transform 0.25s ease;
  }
  .flags li:hover { transform: translateY(-3px) scale(1.15); }
  .flags .no-photos:hover { transform: none; }
  .flags li { transition: transform 0.25s ease, opacity 0.3s ease; }
  .flags button { transition: border-color 0.3s ease; }

  /* Photos fade in when the country filter changes */
  .gallery figure:not([hidden]) { animation: fade 0.5s ease both; }

  /* Gallery: photos fade up as they scroll in (see js/site.js),
     and zoom very slightly under the pointer */
  .reveal { transition: opacity 0.9s ease, transform 0.9s cubic-bezier(.2, .7, .2, 1); }
  .reveal-pending { opacity: 0; transform: translateY(24px); }
  .gallery a { overflow: hidden; }
  .gallery img { transition: transform 0.8s cubic-bezier(.2, .7, .2, 1); }
  .gallery a:hover img { transform: scale(1.025); }

  /* Lightbox opens with a fade, and each photo fades in once loaded */
  .lightbox[open] { animation: fade 0.3s ease; }
  .lightbox img { transition: opacity 0.35s ease; }
  .lightbox img.is-loading { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* Yellow highlight on text that still has to be written. Search the HTML for "todo". */
mark.todo { background: #fff2b3; color: inherit; padding: 0 0.2em; }
