/* oslal — assets/style.css */

@font-face {
  font-family: 'PP Neue Montreal';
  src: url('/assets/PPNeueMontreal-Regular.otf') format('opentype');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
/* Medium — ##### headings in notes */
@font-face {
  font-family: 'PP Neue Montreal';
  src: url('/assets/PPNeueMontreal-Medium.otf') format('opentype');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
/* Italic — *text* in notes */
@font-face {
  font-family: 'PP Neue Montreal';
  src: url('/assets/PPNeueMontreal-Italic.otf') format('opentype');
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
/* Bold — **text** in notes */
@font-face {
  font-family: 'PP Neue Montreal';
  src: url('/assets/PPNeueMontreal-Bold.otf') format('opentype');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --guide: #00ff00;
  --fg: #000000;
  --bg: #ffffff;
  --muted: #888888;

  /* Grid — margins and gutters shrink with the window:
     24px / 16px on wide screens, down to 12px / 8px on phones.
     main.js reads the real values from .page-grid, so the green guides follow. */
  --margin: clamp(12px, calc(12px + (100vw - 800px) * 0.03), 24px);
  --gutter: clamp(8px, calc(8px + (100vw - 800px) * 0.02), 16px);

  /* Row height — JS overrides this with a px value on load/resize.
     Fallback mirrors the same formula: (100vh - 2*margin - 5*gutter)/6. */
  --row-h: calc((100vh - 48px - 80px) / 6);

  /* Typography scale */
  --head-size:  24px;   /* Archives column headers */
  --title-size: 36px;   /* project title */
}

* { margin: 0; padding: 0; box-sizing: border-box; }

::selection { background: var(--guide); }
::-moz-selection { background: var(--guide); }

html, body { width: 100%; min-height: 100%; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'PP Neue Montreal', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 14px;
  letter-spacing: -0.01em;
  line-height: 1.2;
  -webkit-font-smoothing: antialiased;
}

/* Landing is a single viewport (no scroll) */
body[data-page="index"] { overflow: hidden; height: 100%; }

/* ---------- Images: no drag-out, no long-press "Save image" on iPhone/iPad ---------- */
img { -webkit-user-drag: none; user-select: none; -webkit-touch-callout: none; }

/* ---------- Homepage: a 3D model written in pages/home.md fills the screen, behind the tabs ---------- */
body[data-page="index"] model-viewer {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: -1;
  pointer-events: auto;
  background-color: transparent;
  --progress-bar-color: transparent;
}

/* ---------- Page grid: 10 cols, 24px margin, 16px gutter ---------- */
.page-grid {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--gutter);
  padding: var(--margin);
  min-height: 100vh;
  pointer-events: none;
}

/* Landing: fixed 6 rows filling the viewport */
body[data-page="index"] .page-grid {
  height: 100vh;
  grid-template-rows: repeat(6, var(--row-h));
}

/* Scrolling pages: rows snap to the same square-ish height, grow as needed */
body[data-page="archives"] .page-grid,
body[data-page="informations"] .page-grid,
body[data-page="project"] .page-grid {
  grid-auto-rows: var(--row-h);
}
/* Project + Informations: nav + title rows keep the grid height, the note below grows with content */
body[data-page="project"] .page-grid,
body[data-page="informations"] .page-grid {
  grid-template-rows: var(--row-h) var(--row-h);
  grid-auto-rows: auto;
}

/* Archives: nav (1) + headers (2) fixed, list (3) absorbs slack, footer follows */
body[data-page="archives"] .page-grid {
  grid-template-rows: var(--row-h) var(--row-h) minmax(var(--row-h), 1fr);
}

/* ---------- Navigation ---------- */
.nav-item {
  align-self: start;
  pointer-events: auto;
  color: var(--fg);
  text-decoration: none;
  font: inherit;
  letter-spacing: inherit;
  line-height: 1;
  background: none;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
}
.nav-item:hover { opacity: 0.5; }

.nav-name     { grid-column: 1;  grid-row: 1; }
.nav-archives { grid-column: 7;  grid-row: 1; }
.nav-info     { grid-column: 8;  grid-row: 1; }
/* "Work in progress" note, top right — plain text, not a link */
.nav-wip      { grid-column: 9 / span 2; grid-row: 1; justify-self: end; white-space: nowrap; cursor: default; }
.nav-wip:hover { opacity: 1; }

/* Active-page indicator — filled circle */
.nav-item.active::after {
  content: '';
  display: inline-block;
  width: 0.55em;
  height: 0.55em;
  margin-left: 0.45em;
  border-radius: 50%;
  background: var(--fg);
  vertical-align: 0.02em;
}

/* ---------- Links in notes: external ones get ↗ automatically ---------- */
.note a { color: inherit; text-decoration: none; }
.note a:hover { text-decoration: underline; }
.note a[href^="http"]::after,
.note a[href^="mailto"]::after { content: '\2197'; margin-left: 0.1em; }

/* In-text links only (inside a paragraph or list of the note):
   link text in Times New Roman, tracking -33 (= -0.033em); the ↗ stays in PP Neue Montreal */
.note p a, .note li a {
  font-family: 'Times New Roman', Times, serif;
  letter-spacing: -0.033em;
}
.note p a::after, .note li a::after {
  font-family: 'PP Neue Montreal', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  letter-spacing: -0.01em;
  display: inline-block;   /* keeps the hover underline off the arrow */
}

/* ---------- Archives: column headers (row 2) ---------- */
.col-head {
  grid-row: 2;
  align-self: start;
  font-size: var(--head-size);
  line-height: 1;
}
.head-project     { grid-column: 1 / span 5; }
.head-type        { grid-column: 7; }
.head-institution { grid-column: 8 / span 2; }
.head-date        { grid-column: 10; justify-self: end; }

/* ---------- Archives: project list (row 3, grows) ---------- */
.project-list {
  grid-column: 1 / span 10;
  grid-row: 3;
  align-self: start;
  pointer-events: auto;
  position: relative;
}
.project-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--gutter);
  padding: 0.15em 0;
}
.project-row > * { min-width: 0; }
.p-name { grid-column: 1 / span 5; }
.p-type { grid-column: 7; }
.p-inst { grid-column: 8 / span 2; }
.p-date { grid-column: 10; text-align: right; }
.p-name a { color: inherit; text-decoration: none; }
.p-name a:hover { text-decoration: underline; }

/* Hover preview — starts col 3 / row 2, forced to a true 1:1 square.
   Column width comes from viewport WIDTH÷10; --row-h comes from viewport
   HEIGHT÷6 (calibrated so the landing page's 6 rows fill one screen) — the
   two aren't mathematically tied, so "3 cols × 3 rows" isn't reliably square
   on its own. aspect-ratio forces it square regardless of viewport shape.
   Positioned via calc() (not grid-row spanning) because the list's own row
   auto-expands to fit all projects — spanning it would stretch the preview
   with it. */
#list-preview {
  --col-w: calc((100% - (2 * var(--margin)) - (9 * var(--gutter))) / 10);
  position: absolute;
  left: calc(var(--margin) + (2 * (var(--col-w) + var(--gutter))));
  top: calc(var(--margin) + var(--row-h) + var(--gutter));
  width: calc((3 * var(--col-w)) + (2 * var(--gutter)));
  aspect-ratio: 1 / 1;
  pointer-events: none;
  opacity: 0;
  overflow: hidden;
  transition: opacity 0.18s ease;
  z-index: 5;
}
#list-preview.visible { opacity: 1; }
#list-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Project page + Informations: the note ----------
   Built by _layouts/default.html. The note shows as written, top to bottom:
   row 2  : title (# heading) from column 3 | Type 7, Institution 8, Date 10, People below
   row 3+ : the note in columns 3-8, top to bottom: one column of text, images full width */
body[data-page="project"] .page-grid > *,
body[data-page="informations"] .page-grid > * { min-width: 0; }

.project-title {
  grid-column: 3 / span 4;
  grid-row: 2;
  align-self: start;
  font-size: var(--title-size);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.02em;
  pointer-events: auto;
}

/* Same columns as the Archives list: Type 7, Institution 8-9, Date 10 */
.project-meta {
  grid-column: 7 / span 4;
  grid-row: 2;
  align-self: start;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  column-gap: var(--gutter);
  pointer-events: auto;
}
.project-meta > * { min-width: 0; }
.pm-type   { grid-column: 1; }
.pm-inst   { grid-column: 2 / span 2; }
.pm-date   { grid-column: 4; text-align: right; }
.pm-people { grid-column: 1 / span 3; grid-row: 2; margin-top: 0.3em; color: var(--muted); }

.note {
  grid-column: 3 / span 6;
  grid-row: 3;
  align-self: start;
  line-height: 1.3;
  pointer-events: auto;
}
body[data-page="informations"] .note { grid-row: 2; }

/* The note reads like a markdown file: one column of text,
   every image on its own line at the full width of the block. */
.note > * + * { margin-top: 0.8em; }
/* A line break in the note is a line break on the page, as in Obsidian */
.note p { white-space: pre-line; }
/* Horizontal rule (--- in the note): hairline, 0.25pt */
.note hr { border: 0; border-top: 0.25pt solid var(--fg); margin: 1.2em 0; }
.note ul, .note ol { padding-left: 1.2em; }
/* Headings in notes — odd levels only (# is the page title):
   ###    section heading: large, same size as the Archives column headers
   #####  sub-heading: text size, Medium weight */
.note h3 { font-size: var(--head-size); font-weight: 400; line-height: 1; letter-spacing: -0.02em; margin-top: 1.6em; }
.note h5 { font-size: inherit; font-weight: 500; margin-top: 1.4em; }
.note > :first-child { margin-top: 0; }
.note img {
  display: block;
  width: 100%;
  height: auto;
  margin: var(--gutter) 0;
}
.note model-viewer { display: block; width: 100%; aspect-ratio: 1 / 1; }

/* ---------- Medium windows: the note uses the full width ---------- */
@media (max-width: 1199px) {
  .project-title { grid-column: 1 / span 6; }
  .note { grid-column: 1 / span 10; }
}

/* ---------- Phones: everything stacks in one column ---------- */
@media (max-width: 799px) {
  .nav-name     { grid-column: 1 / span 4; }
  .nav-archives { grid-column: 5 / span 3; }
  .nav-info     { grid-column: 8 / span 3; justify-self: end; }
  .nav-wip      { display: none; }   /* no room on phones */

  /* Archives: name + year only, no hover preview */
  .head-type, .head-institution, .p-type, .p-inst, #list-preview { display: none; }
  .head-project, .p-name { grid-column: 1 / span 8; }
  .head-date, .p-date    { grid-column: 9 / span 2; }

  body[data-page="project"] .page-grid { grid-template-rows: var(--row-h) auto auto; }
  .project-title { grid-column: 1 / -1; font-size: 28px; }
  .project-meta  { grid-row: 3; grid-column: 1 / -1; display: block; margin-top: var(--gutter); }
  .project-meta > * { text-align: left; }
  .pm-people { margin-top: 0; }
  .note { grid-column: 1 / -1; grid-row: 4; margin-top: var(--gutter); }
  body[data-page="informations"] .note { grid-row: 2; margin-top: 0; }

  /* Images run edge to edge: no side margins */
  .note img { width: calc(100% + 2 * var(--margin)); max-width: none; margin-left: calc(-1 * var(--margin)); }
}

/* ---------- Footer (© expands on click) ---------- */
.footer {
  grid-column: 1 / span 4;
  grid-row: 6;
  align-self: end;
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
body[data-page="archives"] .footer,
body[data-page="informations"] .footer,
body[data-page="project"] .footer { grid-row: auto; }

.footer .full {
  display: inline-block;
  max-width: 0;
  overflow: hidden;
  vertical-align: bottom;
  opacity: 0;
  transition: max-width 0.4s ease, opacity 0.3s ease;
}
.footer.open .full { max-width: 30ch; opacity: 1; }

/* ---------- Reveal animations ---------- */
.reveal {
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.5s ease, transform 0.5s ease;
  transition-delay: calc(var(--i, 0) * 40ms);
}
.reveal.in-view { opacity: 1; transform: none; }

/* Nav fade/slide on load */
@keyframes navIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.nav-item {
  animation: navIn 0.5s ease both;
}
.nav-name     { animation-delay: 0.00s; }
.nav-archives { animation-delay: 0.06s; }
.nav-info     { animation-delay: 0.12s; }
.nav-wip      { animation-delay: 0.18s; }

/* Project title rises in */
.project-title { animation: navIn 0.6s ease both; animation-delay: 0.1s; }

/* ---------- Grid overlay ---------- */
#grid-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 100;
}
#grid-canvas.visible { opacity: 1; }

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
  .nav-item, .project-title { animation: none; }
  .footer .full { transition: none; }
}
