/* ==========================================================================
   Mălin Neamțu: portfolio
   One stylesheet, kept minimal: two colours (black and #fafafa, set in
   /admin → Theme), Segmentor-03 for all text, thin rules, no decoration.
   Only the big menu on the splash moves (class .seg).
   Tokens (colours, sizes) live in :root so they are easy to change.
   ========================================================================== */

@font-face {
  font-family: "Segmentor";
  src: url("fonts/Segmentor.woff2") format("woff2");
  font-display: swap; /* show fallback text while the font loads */
}

:root {
  --bg: #000000;
  --fg: #fafafa;
  --muted: #fafafa;
  --line: #fafafa;
  --stroke: 0px;                      /* image outlines; 0 = none */
  --stroke-color: #fafafa;
  --accent: #fafafa;

  --pad: clamp(12px, 1.6vw, 24px);    /* page edge */
  --gap: clamp(8px, 1vw, 16px);       /* between images */

  --font: "Segmentor", ui-monospace, monospace;   /* the name: always Segmentor */
  --font-text: var(--font);                        /* everything else; can be swapped in /admin → Theme */
  --text-s: 13px;
  --text-m: 15px;
  --text-l: clamp(22px, 2.4vw, 34px);

  /* The four Segmentor axes. script.js changes these as the mouse moves or
     the phone tilts; every element with class .seg follows them. */
  --aaaa: 0;
  --bbbb: 0;
  --cccc: 0;
  --dddd: 0;
}

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

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-text);
  font-size: var(--text-m);
  line-height: 1.4;
}

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

/* Links: same colour as the text; a thin underline appears on hover. */
a { color: inherit; text-decoration: none; }
a:hover,
a[aria-current="page"] { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
/* Links inside running text are always underlined, so they can be found. */
.project-text a,
.project-meta dd a,
.cv-list .what a { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

:focus-visible { outline: 1px solid var(--fg); outline-offset: 3px; }

h1, h2 { font-weight: normal; }

.plain-list { list-style: none; margin: 0; padding: 0; }

/* Text that moves with the mouse / tilt. */
.seg {
  font-family: var(--font);
  font-variation-settings:
    "AAAA" var(--aaaa), "BBBB" var(--bbbb), "CCCC" var(--cccc), "DDDD" var(--dddd);
}

/* --- Header (every page except the splash) -------------------------------- */

.site-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  padding: var(--pad);
}
.site-nav { display: flex; gap: 1.5rem; align-items: baseline; }

main { padding: 0 var(--pad); }

/* Every page is at least as tall as the window, and <main> takes the
   spare room, so the footer sits at the bottom even on short pages
   (a "sticky footer" made with flexbox). */
body {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }

/* --- Splash ------------------------------------------------------------------ */

body.is-splash {
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
/* Name top left, "Contact" top right. */
.splash-header { align-items: flex-start; }
.contact-menu { position: relative; text-align: right; }
/* The list hangs under "Contact", right-aligned, over the page. */
.contact-menu ul {
  position: absolute;
  right: 0;
  top: calc(100% + 0.4rem);
  z-index: 2;
  white-space: nowrap;
  background: var(--bg);
}

.is-splash main {
  flex: 1;
  display: flex;
  align-items: center;
  padding: 0 var(--pad) var(--pad);
}
/* The three big links on one line: Projects on the left margin, Type in
   the exact middle, About on the right margin. A grid of three columns,
   1fr | auto | 1fr, keeps the middle word centred however long the
   outer words are. */
.splash-menu { width: 100%; }
.splash-menu ul {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: baseline;
  gap: 1rem;
}
.splash-menu li:first-child { justify-self: start; }
.splash-menu li:nth-child(2) { justify-self: center; }
.splash-menu li:last-child { justify-self: end; }
.splash-menu a {
  display: inline-block;
  font-size: clamp(28px, 7vw, 120px);
  line-height: 1.1;
  white-space: nowrap;
}
/* Underline on hover (mouse), keyboard focus, and on tap (phones:
   script.js adds .is-tapped when a finger touches the link). */
.splash-menu a:hover,
.splash-menu a:focus-visible,
.splash-menu a.is-tapped {
  text-decoration: underline;
  text-decoration-thickness: 0.05em;
  text-underline-offset: 0.1em;
}
.splash-menu a:focus-visible { outline: none; }

/* Phones: the three words stacked, all the same size (script.js §2 sizes
   them so the longest word fills the space between the margins);
   Projects on the left, Type centred, About on the right, as on desktop. */
@media (max-width: 700px) {
  .splash-menu ul { grid-template-columns: 1fr; gap: 0; }
  .splash-menu a { font-size: 16vw; line-height: 1.05; }
}

/* Only shown on iPhone/iPad, where tilting needs one tap of permission. */
.splash-header .motion-btn { position: absolute; left: 50%; transform: translateX(-50%); }
.motion-btn {
  font: inherit;
  color: inherit;
  background: none;
  border: 1px solid var(--line);
  padding: 0.1rem 0.5rem;
  cursor: pointer;
}

/* --- Index (Projects) ------------------------------------------------------- */

.index { list-style: none; margin: clamp(1.5rem, 7vh, 5rem) 0 0; padding: 0; }
.index-head,
.index-row {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 2fr) minmax(0, 1fr);
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
}
.index-head { font-size: var(--text-s); }
.index-year,
.index-head span:last-child { text-align: right; }
.index-row:hover { text-decoration: none; }
.index-row:hover .index-title { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }

/* Phones: title and year on one line, client underneath. */
@media (max-width: 700px) {
  .index-head { display: none; }
  .index-row { grid-template-columns: minmax(0, 1fr) auto; row-gap: 0.1rem; }
  .index-client { grid-row: 2; font-size: var(--text-s); }
  .index-year { grid-column: 2; grid-row: 1; }
}

/* Full-screen cover behind the list while a row is hovered (computers only).
   All covers are stacked in .index-bg, invisible; script.js adds .is-active
   to the hovered project's cover, which fades in. z-index -1 puts the layer
   behind the text but above the black page background. */
.index-bg { display: none; }
@media (hover: hover) {
  .index-bg {
    display: block;
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
  }
  .index-bg img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    transition: opacity 0.35s ease;
  }
  .index-bg img.is-active { opacity: 1; }

  /* "difference" blending: light text over a light image turns dark and
     vice versa, so the list stays readable on any cover. Over plain black
     it looks exactly as before. */
  .is-work .site-header,
  .is-work .index,
  .is-work .site-footer { mix-blend-mode: difference; }
}

/* --- Project page ------------------------------------------------------------ */

.project-title {
  margin: 2rem 0 1.5rem;
  font-size: clamp(32px, 5vw, 72px);
  line-height: 1;
  overflow-wrap: anywhere;
}

.project-info {
  display: grid;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
}
@media (min-width: 900px) {
  .project-info { grid-template-columns: 1fr 2fr; gap: var(--gap); }
}

.project-meta {
  margin: 0;
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 0.3rem 1.2rem;
  font-size: var(--text-s);
  align-content: start;
}
.project-meta dd { margin: 0; }

.project-text { max-width: 44em; }
.project-text p { margin: 0 0 1em; }

.project-links { list-style: none; padding: 0; margin: 0; font-size: var(--text-s); }

/* Gallery rows: images in a row share the width by their ratio (--r, set
   in project.njk), which gives them all the same height. */
.gallery { display: grid; gap: var(--gap); }
.gallery-section { margin: 2.5rem 0 0; font-size: var(--text-s); }
.gallery-row { display: flex; gap: var(--gap); align-items: flex-start; }
.gallery figure { margin: 0; flex: var(--r) 1 0; min-width: 0; }
.gallery figcaption { margin-top: 0.4rem; font-size: var(--text-s); }
.gallery img, .gallery video { display: block; width: 100%; height: auto; outline: var(--stroke) solid var(--stroke-color); outline-offset: calc(var(--stroke) * -1); }
/* A lone tall image or video should not be taller than the screen. */
.gallery-row[data-count="1"] { justify-content: center; }
.gallery-row[data-count="1"] figure { flex: none; max-width: 100%; width: min(100%, calc(88vh * var(--r))); }

/* Phones: long rows wrap into lines of three (or two for rows of four). */
@media (max-width: 700px) {
  .gallery-row { flex-wrap: wrap; }
  .gallery-row:not([data-count="1"]):not([data-count="2"]):not([data-count="3"]) figure {
    flex: 0 0 calc((100% - 2 * var(--gap)) / 3);
  }
  .gallery-row[data-count="4"] figure { flex: 0 0 calc((100% - var(--gap)) / 2); }
}

.project-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--line);
  font-size: var(--text-s);
}

/* --- Type ---------------------------------------------------------------------- */

.tester-list { list-style: none; margin: 0; padding: 0; }
.tester { border-top: 1px solid var(--line); padding: 0.55rem 0 2.5rem; }
.tester:last-child { border-bottom: 1px solid var(--line); }

.tester-bar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  font-size: var(--text-s);
}
.tester-name { margin: 0; font-size: var(--text-m); }

/* "Options": a dropdown (<details>) with size, styles and axes. The panel
   hangs under the word, right-aligned, over the sample. */
.tester-options { position: relative; }
.dropdown summary { cursor: pointer; list-style: none; }
.dropdown summary::-webkit-details-marker { display: none; }
.dropdown summary:hover,
.dropdown[open] summary { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.tester-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 0.5rem);
  z-index: 3;
  display: grid;
  gap: 0.6rem;
  width: max-content;
  max-width: calc(100vw - 2 * var(--pad));
  padding: 0.8rem 1rem;
  background: var(--bg);
  border: 1px solid var(--line);
}
.tester-styles { display: flex; gap: 0.75rem; }
.tester-styles button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}
.tester-styles button[aria-pressed="true"],
.tester-styles button:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 0.2em; }
.tester-size,
.tester-axes label { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; }
.tester-axes { display: grid; grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr)); gap: 0.6rem 1.5rem; min-width: min(22rem, 80vw); }
.tester-axes:empty { display: none; }
.tester input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 7rem;
  height: 14px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
/* Slider in the two colours: a 1px line and a small round knob. */
.tester input[type="range"]::-webkit-slider-runnable-track { height: 1px; background: var(--fg); }
.tester input[type="range"]::-moz-range-track { height: 1px; background: var(--fg); }
.tester input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 11px; height: 11px; margin-top: -5px;
  border: 0; border-radius: 50%; background: var(--fg);
}
.tester input[type="range"]::-moz-range-thumb { width: 11px; height: 11px; border: 0; border-radius: 50%; background: var(--fg); }

/* The sample stays on one line (white-space: pre keeps only the line
   breaks you type with Return); script.js shrinks it to fit the width.
   The padding leaves room for fonts whose letters reach above or below
   their stated height (e.g. Cocoscript). */
.tester-sample {
  margin: 0.5rem 0 0;
  padding: 0.18em 0 0.12em;
  font-size: var(--size, min(72px, 13vw));
  line-height: 1.15;
  white-space: pre;
  overflow: hidden;
  outline: none;
  cursor: text;
}

/* --- About ------------------------------------------------------------------- */

.about { margin: 2rem 0 4rem; }

.cv { display: grid; gap: 3rem var(--gap); margin-bottom: 3rem; }
@media (min-width: 900px) { .cv { grid-template-columns: 1fr 1fr; } }
.cv h2 {
  margin: 0 0 0.5rem;
  padding-bottom: 0.55rem;
  font-size: var(--text-m);
  border-bottom: 1px solid var(--line);
}
.cv-list { list-style: none; margin: 0; padding: 0; }
.cv-list li {
  display: grid;
  grid-template-columns: 9em 1fr;
  gap: 1rem;
  font-size: var(--text-s);
  margin-bottom: 0.45rem;
}

/* --- 404 ----------------------------------------------------------------- */

.not-found { min-height: 50vh; padding-top: 2rem; }

/* --- Footer -------------------------------------------------------------- */

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin: 4rem var(--pad) 0;
  padding: 0.55rem 0 var(--pad);
  border-top: 1px solid var(--line);
  font-size: var(--text-s);
}

/* ==========================================================================
   Motion: only a soft fade between pages.
   ========================================================================== */

@view-transition { navigation: auto; }
::view-transition-old(root) { animation: page-out 0.18s ease-in both; }
::view-transition-new(root) { animation: page-in 0.3s ease-out both; }
@keyframes page-out { to { opacity: 0; } }
@keyframes page-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after, ::view-transition-group(*), ::view-transition-old(*), ::view-transition-new(*) {
    animation: none !important;
    transition: none !important;
  }
}
