/* ============================================================
   leonardo benzoni — retro UI (old-Photoshop document window)
   One viewport, Photoshop-style chrome, fixed frame, scroll inside.
   ============================================================ */

/* ---------- Fonts ---------- */

@font-face {
  font-family: "Helvetica Now Display";
  src: url("assets/HelveticaNowDisplay-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Heldane Text";
  src: url("assets/test-heldane-text-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ---------- Tokens ---------- */

:root {
  --frame-pad: 48px;
  --titlebar-h: 28px;
  --statusbar-h: 26px;
  --scrollbar-w: 13px;
  --window-radius: 5px;

  --page-bg: #ffffff;
  --win-border: #d4d4d4;
  --chrome-top: #f7f7f7;
  --chrome-bot: #e9e9e9;
  --chrome-border: #cfcfcf;
  --canvas-bg: #ffffff;

  --text: #111111;
  --muted: #1b1b1b;
  --chrome-text: #5d5d5d;
  --tile: #ededed;

  --field-bg: #e8e8e8;
  --field-border: #cccccc;
  --scroll-groove: #ececec;
  --scroll-thumb: #c2c2c2;

  --light-close: #ff6232;
  --light-mono: #6e6d6b;
  --light-stroke: rgba(255, 255, 255, 0.42);

  --win-shadow: rgba(0, 0, 0, 0.18);
}

/* ---------- Dark mode (Photoshop dark workspace) ---------- */

body.dark {
  --page-bg: #000000;
  --win-border: #2c2c2e;
  --chrome-top: #3b3b3d;
  --chrome-bot: #313133;
  --chrome-border: #202021;
  --canvas-bg: #393a3c;

  --text: #ededed;
  --muted: #c6c6c6;
  --chrome-text: #bdbdbd;
  --tile: #686868;

  --field-bg: #3a3a3c;
  --field-border: #202021;
  --scroll-groove: #2a2a2c;
  --scroll-thumb: #565658;

  --light-mono: #9a9a9c;
  --light-stroke: rgba(255, 255, 255, 0.16);

  --win-shadow: rgba(0, 0, 0, 0.55);
}

/* Smooth the theme cross-fade on the colour-bearing elements. */
.name, .role, .tagline, .socials a, .titlebar__name,
.statusbar__field { transition: color 0.4s ease; }

/* ---------- Reset ---------- */

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: var(--page-bg);
  color: var(--text);
  font-family: "Heldane Text", "Times New Roman", Times, serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding: var(--frame-pad);
  transition:
    padding 0.55s cubic-bezier(0.32, 0.72, 0, 1),
    background-color 0.4s ease,
    color 0.4s ease;
}

button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; text-decoration: none; }

/* ---------- Window ---------- */

.window {
  /* Cursor-driven directional shadow (set live by script.js). */
  --sx: 0px;
  --sy: 0px;
  position: relative;
  width: 100%;
  height: 100%;
  background: var(--canvas-bg);
  border: 1px solid var(--win-border);
  border-radius: var(--window-radius);
  box-shadow:
    0 2px 10px rgba(0, 0, 0, 0.05),
    var(--sx) var(--sy) 30px var(--win-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform-origin: 50% 100%;
  transition:
    box-shadow 0.2s ease-out,
    border-radius 0.55s cubic-bezier(0.32, 0.72, 0, 1),
    border-color 0.4s ease,
    background-color 0.4s ease,
    transform 0.46s cubic-bezier(0.4, 0, 0.5, 1),
    opacity 0.4s ease;
}

/* Very subtle film grain over the whole window (chrome + canvas). */
.window::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 180px 180px;
  opacity: 0.045;
}
body.dark .window::after { opacity: 0.07; }

/* ---------- Fullscreen ----------
   Window fills the viewport; the chrome (title bar, status bar, scrollbar)
   melts away. Cursor to the very top peeks the title bar back down so you
   can exit (click the fullscreen light) — or press Escape. */

body.is-full { padding: 0; }
body.is-full .window { border-radius: 0; border-color: transparent; }
body.is-full .titlebar {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 6;
  transform: translateY(-100%);
}
body.is-full.bar-peek .titlebar { transform: translateY(0); }
body.is-full .statusbar { display: none; }
body.is-full .scroll-v { opacity: 0; pointer-events: none; }

/* ---------- Close → minimize to dock ---------- */

body.is-closed .window {
  transform: translateY(34vh) scale(0.08);
  opacity: 0;
  pointer-events: none;
}

.dock {
  position: fixed;
  left: 50%;
  bottom: 14px;
  z-index: 50;
  transform: translate(-50%, 165%);
  padding: 7px;
  background: rgba(245, 245, 245, 0.72);
  border: 1px solid var(--win-border);
  border-radius: 16px;
  backdrop-filter: blur(20px) saturate(1.6);
  -webkit-backdrop-filter: blur(20px) saturate(1.6);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.16);
  transition: transform 0.42s cubic-bezier(0.16, 1, 0.3, 1);
}
body.dock-peek .dock { transform: translate(-50%, 0); }

.dock__app {
  display: block;
  width: 58px;
  height: 42px;
  transition: transform 0.18s ease;
}
.dock__app:hover { transform: translateY(-7px) scale(1.04); }

.dock__win {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--canvas-bg);
  border: 1px solid var(--win-border);
  border-radius: 5px;
  overflow: hidden;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
}
.dock__bar {
  display: block;
  height: 10px;
  background: linear-gradient(var(--chrome-top), var(--chrome-bot));
  border-bottom: 1px solid var(--chrome-border);
}
body.dark .dock { background: rgba(40, 40, 42, 0.72); }

/* ---------- Title bar ---------- */

.titlebar {
  position: relative;
  flex: 0 0 var(--titlebar-h);
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  background: linear-gradient(var(--chrome-top), var(--chrome-bot));
  border-bottom: 1px solid var(--chrome-border);
  user-select: none;
  transition:
    transform 0.38s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.4s ease,
    border-color 0.4s ease;
}

/* Traffic lights, left. */
.lights {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}

.light {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--light-mono);
  /* No symbols — just a very subtle lighter stroke for definition. */
  box-shadow: inset 0 0 0 1px var(--light-stroke);
  transition: background-color 0.4s ease, box-shadow 0.4s ease, filter 0.15s ease;
}
.light--close { background: var(--light-close); }
.light:hover { filter: brightness(1.06); }

/* Centered filename + zoom (Photoshop title). */
.titlebar__title {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 6px;
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
}
/* font-size here matches the filename text so the icon's em tracks it. */
.titlebar__icon { display: inline-flex; line-height: 0; font-size: 14px; }
/* width auto keeps the 38:50 ratio. ~1.5x the cap-height size Leo asked for. */
.titlebar__icon img { height: 1.18em; width: auto; display: block; }
.titlebar__name {
  font-family: "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 0.01em;
  color: var(--chrome-text);
}

/* ---------- Canvas (document) ---------- */

.canvas {
  position: relative;
  flex: 1 1 auto;
  background: var(--canvas-bg);
  overflow: hidden;
  transition: background-color 0.4s ease;
}

/* ---------- Name (vertically centred, left) ---------- */

.name {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  margin: 0;
  max-width: calc(50% - 60px);
  font-family: "Helvetica Now Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 700;
  font-size: 15px;
  line-height: 1;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--text);
  overflow-wrap: anywhere;
  caret-color: transparent;
  outline: none;
}

.name::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 0.9em;
  background: currentColor;
  /* The gap is a real trailing space in the content now, so the caret sits
     right after it (where typed text actually lands). */
  margin-left: 1px;
  vertical-align: -0.06em;
  animation: blink 1.1s infinite;
}

@keyframes blink {
  0%, 49.99% { opacity: 1; }
  50%, 100%  { opacity: 0; }
}

/* ---------- Meta: role + tagline (bottom-left) ---------- */

.meta {
  position: absolute;
  left: 14px;
  bottom: 14px;
}
.role, .tagline {
  margin: 0;
  font-family: "Heldane Text", "Times New Roman", Times, serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--muted);
  white-space: nowrap;
}
.role a { transition: opacity 0.15s ease; }
.role a:hover { opacity: 0.5; }

/* ---------- Socials (bottom, left of the gallery) ---------- */

.socials {
  position: absolute;
  right: calc(50% + 16px);
  bottom: 14px;
  display: flex;
  flex-direction: column;
  font-family: "Heldane Text", "Times New Roman", Times, serif;
  font-weight: 400;
  font-size: 16px;
  line-height: 1.32;
  letter-spacing: -0.01em;
  color: var(--muted);
}
.socials a { width: max-content; transition: opacity 0.15s ease; }
.socials a:hover { opacity: 0.5; }

/* ---------- Gallery (right half, scroll, flat tiles) ---------- */

.work {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: 50%;
  padding: 12px 28px 12px 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.work::-webkit-scrollbar { width: 0; height: 0; display: none; }

.work__tile {
  background: var(--tile);
  border-radius: 6px;
  aspect-ratio: 313 / 321;
  transition: background-color 0.4s ease;
}

/* ---------- Vertical scrollbar (right edge) ---------- */

.scroll-v {
  position: absolute;
  top: 0;
  bottom: 0;
  right: 0;
  width: var(--scrollbar-w);
  background: var(--scroll-groove);
  border-left: 1px solid var(--chrome-border);
  transition: background-color 0.4s ease, opacity 0.3s ease;
}
.scroll-v__thumb {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 120px;
  background: var(--scroll-thumb);
}

/* ---------- Status bar (Photoshop bottom) ---------- */

.statusbar {
  position: relative;
  flex: 0 0 var(--statusbar-h);
  height: var(--statusbar-h);
  display: flex;
  align-items: stretch;
  background: linear-gradient(var(--chrome-top), var(--chrome-bot));
  border-top: 1px solid var(--chrome-border);
  user-select: none;
  transition: background 0.4s ease, border-color 0.4s ease;
}

.statusbar__field {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  font-family: "SF Pro", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 400;
  font-size: 14px;
  color: var(--chrome-text);
  border-right: 1px solid var(--field-border);
}
.statusbar__zoom { background: var(--field-bg); }
.statusbar__chevron { opacity: 0.7; }

/* Remaining space is a horizontal scrollbar groove + thumb. */
.statusbar__scroll {
  position: relative;
  flex: 1 1 auto;
  background: var(--scroll-groove);
}
.statusbar__thumb {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 80px;
  background: var(--scroll-thumb);
}

/* ============================================================
   Responsive — tablet + phone (mirrors the main branch)
   Below 1340px the document stacks: name → role/tagline → socials at
   the top, gallery full-width below and scrolling. The vertical
   scrollbar hides (the gallery scrolls normally).
   ============================================================ */

@media (max-width: 1340px) {
  .canvas {
    display: flex;
    flex-direction: column;
    padding: 20px 18px 0;
  }

  .name { position: static; transform: none; max-width: none; margin: 0; }
  .meta { position: static; margin: 12px 0 0; }
  .role, .tagline { white-space: normal; }

  .socials {
    position: static;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 16px;
    margin: 14px 0 0;
  }

  .work {
    position: static;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    margin-top: 20px;
    padding: 0 0 16px;
    grid-template-columns: repeat(2, 1fr);
  }
  /* First row sits flush against the scroll edge — square its top corners. */
  .work__tile:nth-child(-n + 2) {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
  }

  .scroll-v { display: none; }
}

@media (max-width: 640px) {
  :root { --frame-pad: 24px; }

  .work { grid-template-columns: 1fr; }
  /* Single column: only tile 1 is the top row, so tile 2 is rounded again. */
  .work__tile:nth-child(2) {
    border-top-left-radius: 6px;
    border-top-right-radius: 6px;
  }

  /* Trim the title to just the icon + img<date>.jpg (drop "@ 33.3% ..."). */
  .titlebar__meta { display: none; }
}

/* ---------- Reduced motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .name::after { animation: none; }
}
