/* ==========================================================================
   BASE.CSS — tokens, themes, the area layout and the status bar.

   Layout (like Blender's areas):
     wide   [ node editor | viewer ]          desktop, landscape tablet
     short  [ editor | viewer ], compact      landscape phone
     tall   [ viewer ] over [ editor ]         phone, portrait tablet
   The mode class (is-tall / is-short) is set on <html> by JS.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Archivo", "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;

  --gap: 4px;                       /* space between areas */
  --area-radius: 8px;
  --area-hdr: 32px;
  --editor-w: clamp(440px, 36vw, 600px);
  --editor-h: 172px;                /* tall mode only (node area under the viewer) */
  --status-h: 30px;

  --ease-out: cubic-bezier(.2, .8, .2, 1);

  /* overridden from content.js */
  --accent: #f5a524;
  --hdr-personal: #7a2a3a;
  --hdr-work: #8a4f1e;
  --hdr-cv: #2a5f86;
  --hdr-contact: #2f6b3a;
  --cable-work: #e3c446;
  --cable-cv: #62a8dc;
  --cable-contact: #66c27a;
  --cable-idle: #8a8a8a;
}

/* Dark: Blender's node editor palette */
:root, :root[data-theme="dark"] {
  color-scheme: dark;
  --app: #141414;                   /* the gaps between areas */
  --area-header: #2b2b2b;
  --canvas: #1d1d1d;
  --dot: #303030;
  --dot-major: #3d3d3d;
  --viewer: #232323;
  --surface: #2c2c2c;               /* cards, rows inside the viewer */
  --node: #303030;
  --node-edge: #121212;
  --node-shadow: 0 1px 0 rgba(255,255,255,.04) inset, 0 8px 22px rgba(0,0,0,.42), 0 2px 4px rgba(0,0,0,.35);
  --node-shadow-lift: 0 1px 0 rgba(255,255,255,.05) inset, 0 18px 40px rgba(0,0,0,.5), 0 4px 10px rgba(0,0,0,.4);
  --field: #545454;
  --field-hover: #626262;
  --field-sunken: #1f1f1f;
  --text: #e8e8e8;
  --text-dim: #a8a8a8;
  --text-faint: #7d7d7d;
  --hdr-text: #f2f2f2;
  --hdr-mix: 100%;
  --hdr-mix-base: #000;
  --active: #ffffff;
  --sock-edge: #000;
  --cable-shade: rgba(0,0,0,.55);
  --cable-mix: 100%;
  --rule: rgba(255,255,255,.09);
  --logo-filter: none;
  --name: #ec8496;                  /* your name: a light tint of the Personal red */
  --frame-text: #a8a8a8;            /* text on the frame colour (status bar, flaps) */
  --grip: #3a3a3a;
}

/* Light: cool neutral greys so the coloured headers still lead */
:root[data-theme="light"] {
  color-scheme: light;
  --app: #b9bcc1;
  --area-header: #d6d8dc;
  --canvas: #e3e4e6;
  --dot: #c7c9cd;
  --dot-major: #b3b6bb;
  --viewer: #f4f5f6;
  --surface: #e8e9eb;
  --node: #f8f8f9;
  --node-edge: #a3a7ad;
  --node-shadow: 0 1px 0 rgba(255,255,255,.8) inset, 0 8px 20px rgba(30,34,40,.14), 0 2px 4px rgba(30,34,40,.10);
  --node-shadow-lift: 0 1px 0 rgba(255,255,255,.8) inset, 0 18px 36px rgba(30,34,40,.2), 0 4px 10px rgba(30,34,40,.12);
  --field: #dcdee1;
  --field-hover: #d0d3d7;
  --field-sunken: #eceef0;
  --text: #1b1c1e;
  --text-dim: #55585e;
  --text-faint: #7b7f86;
  --hdr-text: #1b1c1e;
  --hdr-mix: 42%;
  --hdr-mix-base: #fff;
  --active: #1b1c1e;
  --sock-edge: rgba(0,0,0,.55);
  --cable-shade: rgba(0,0,0,.22);
  --cable-mix: 88%;
  --rule: rgba(0,0,0,.1);
  --logo-filter: invert(1);         /* white logo → black (see content.js) */
  --name: #8c2238;
  --frame-text: #24262a;
  --grip: #9a9ea5;
}

/* Mode metrics */
.is-short { --editor-w: 330px; --status-h: 30px; }
.is-tall  { --status-h: 34px; }
@media (min-width: 600px) { .is-tall { --editor-h: 220px; } }

/* ---------- 2. Reset ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;                 /* the page itself never scrolls */
  overscroll-behavior: none;
  background: var(--app);
}
body {
  font-family: var(--font-ui);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.icon { width: 16px; height: 16px; flex: none; }

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; z-index: 100; left: 12px; top: 12px;
  padding: 10px 14px; border-radius: 6px;
  background: var(--accent); color: #1b1c1e; font-weight: 600; text-decoration: none;
  transform: translateY(-160%);
}
.skip-link:focus { transform: none; }

/* ---------- 3. Areas ----------
   wide / short:  [ brand  | viewer ]     tall:  [ brand  ]
                  [ editor | viewer ]            [ viewer ]
                                                 [ editor ]
   The brand block and the editor share one column and read as one area. */
.app {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: var(--gap);
  padding: calc(var(--gap) + env(safe-area-inset-top, 0px)) calc(var(--gap) + env(safe-area-inset-right, 0px)) 0 calc(var(--gap) + env(safe-area-inset-left, 0px));
}

.workspace {
  position: relative;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--editor-w) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "brand viewer" "editor viewer";
  column-gap: var(--gap);
}
.brand        { grid-area: brand; }
.area--editor { grid-area: editor; }
.area--viewer { grid-area: viewer; }

.is-tall .workspace {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) var(--editor-h);
  grid-template-areas: "brand" "viewer" "editor";
  row-gap: var(--gap);
}

.area {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: var(--area-radius);
}
.area--editor { display: grid; border-radius: 0 0 var(--area-radius) var(--area-radius); }
.area--viewer { overflow: visible; }   /* the book cover may swing past its edge */
.is-tall .area--editor { border-radius: var(--area-radius); }

/* ---------- Title block (thick header) ---------- */
.brand {
  min-width: 0;
  padding: 22px 24px 20px;
  border-radius: var(--area-radius) var(--area-radius) 0 0;
  background: var(--area-header);
}
.brand__h1 { margin: 0; display: grid; gap: 8px; font-weight: inherit; }
.brand__title {
  font-family: var(--font-display);
  font-variation-settings: "wdth" 125;      /* wide, like the logo */
  font-weight: 700;
  font-size: min(var(--brand-heading-size, 36px), 2.6vw + 10px);   /* size set in content.js → brand */
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.brand__meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 10px; min-width: 0; }
.brand__name { font-size: var(--brand-name-size, 15px); font-weight: 500; line-height: 1.2; color: var(--name); }
.brand__role {                     /* the title next to your name, after a thin divider */
  display: inline-flex; align-items: center; gap: 10px;
  font-size: var(--brand-role-size, 15px); font-weight: 400; line-height: 1.2;
  color: var(--text-dim);
}
.brand__role::before { content: ""; width: 1px; height: .9em; background: currentColor; opacity: .5; }
.is-short .brand { padding: 12px 16px; }
.is-short .brand__title { font-size: min(var(--brand-heading-size, 36px) * .56, 22px); }
.is-short .brand__name { font-size: calc(var(--brand-name-size, 15px) * .87); }
.is-short .brand__role { font-size: calc(var(--brand-role-size, 15px) * .87); }
.is-tall .brand { padding: 12px 14px 11px; border-radius: var(--area-radius); }
.is-tall .brand__h1 { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.is-tall .brand__title { font-size: min(var(--brand-heading-size, 36px) * .67, 5.4vw); }
.is-tall .brand__meta { flex-direction: column; align-items: flex-end; gap: 2px; flex: none; text-align: right; }
.is-tall .brand__name { font-size: calc(var(--brand-name-size, 15px) * .87); white-space: nowrap; }
.is-tall .brand__role { font-size: calc(var(--brand-role-size, 15px) * .8); white-space: nowrap; }
.is-tall .brand__role::before { display: none; }

/* ---------- Flaps ----------
   Shapes in the frame colour that flow into an area with a long S-curve.
   .flap__body holds the content; .flap__curve is the curved edge.        */
.flap {
  position: absolute;
  display: flex;
  color: var(--frame-text);
  font-size: 12.5px;
  line-height: 1.35;
}
.flap__body {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  background: var(--app);
}
.flap__curve { flex: none; display: block; width: 56px; height: 100%; fill: var(--app); }

/* ---------- Divider: drag to resize the two sides ---------- */
.splitter {
  position: absolute;
  z-index: 6;
  top: 0; bottom: 0;
  left: var(--editor-w);
  width: var(--gap);
  cursor: col-resize;
  touch-action: none;
  outline: none;
}
.splitter::before { content: ""; position: absolute; inset: 0 -7px; }        /* bigger hit area */
.splitter::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 4px; height: 44px;
  border-radius: 4px;
  transform: translate(-50%, -50%);
  background: var(--grip);
  transition: height 180ms var(--ease-out), background-color 180ms;
}
.splitter:hover::after,
.splitter.is-dragging::after,
.splitter:focus-visible::after { height: 72px; background: var(--accent); }
.is-tall .splitter {
  top: auto; left: 0; right: 0;
  bottom: var(--editor-h);
  width: auto; height: var(--gap);
  cursor: row-resize;
}
.is-tall .splitter::before { inset: -10px 0; }
.is-tall .splitter::after { width: 44px; height: 4px; }
.is-tall .splitter:hover::after, .is-tall .splitter.is-dragging::after, .is-tall .splitter:focus-visible::after { width: 72px; height: 4px; }
@media (pointer: coarse) { .splitter::before { inset: 0 -12px; } .is-tall .splitter::before { inset: -14px 0; } }
body.is-resizing, body.is-resizing * { cursor: col-resize !important; user-select: none; }
body.is-resizing.is-rows, body.is-resizing.is-rows * { cursor: row-resize !important; }

/* The cable from Personal into the viewer, over both areas.
   Nothing inside it may catch the pointer: an overlay with clickable bits
   makes Chrome send mouse-wheel scrolling to it instead of the page below. */
.link-out {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  overflow: visible;
  pointer-events: none;
  z-index: 5;
}
.link-out * { pointer-events: none !important; }

/* ---------- 4. Status bar ---------- */
.statusbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  height: calc(var(--status-h) + env(safe-area-inset-bottom, 0px));
  padding: 0 calc(12px + env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) calc(12px + env(safe-area-inset-left, 0px));
  font-size: 12px;
  color: var(--frame-text);
}
.statusbar p { margin: 0; display: flex; align-items: center; gap: 8px; min-width: 0; }
.statusbar p > span.long, .statusbar p > span.short, .status-avail > span:not(.status-dot) { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.statusbar .short { display: none; }
.status-right { justify-content: flex-end; }
/* On wide screens availability lives in the bottom-left flap and
   "Simple version" sits in the node editor, so the bar only keeps the right side. */
:root:not(.is-tall):not(.is-short) .statusbar .status-avail,
:root:not(.is-tall):not(.is-short) .statusbar .simple-link { visibility: hidden; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #3fbf6a; box-shadow: 0 0 0 3px color-mix(in srgb, #3fbf6a 22%, transparent); }
.status-dot[data-status="soon"] { background: #e3a531; box-shadow: 0 0 0 3px color-mix(in srgb, #e3a531 22%, transparent); }
.status-dot[data-status="busy"] { background: #e0533f; box-shadow: 0 0 0 3px color-mix(in srgb, #e0533f 22%, transparent); }

.simple-link {
  display: inline-flex; align-items: center;
  height: 22px; padding: 0 10px;
  border-radius: 999px;
  background: var(--field);
  color: var(--text);
  font-size: 12px; font-weight: 500;
  text-decoration: none; white-space: nowrap;
}
.simple-link:hover { background: var(--field-hover); }

/* Theme switch */
.theme-switch {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 2px 2px 2px 4px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--frame-text);
}
.theme-switch .icon { width: 13px; height: 13px; }
.theme-switch__track {
  position: relative;
  width: 30px; height: 16px;
  border-radius: 999px;
  background: var(--field-sunken);
  box-shadow: inset 0 0 0 1px var(--node-edge);
}
.theme-switch__track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--text);
  transition: transform 220ms var(--ease-out);
}
.theme-switch[aria-checked="true"] .theme-switch__track::after { transform: translateX(14px); }

.is-tall .statusbar { gap: 8px; font-size: 11.5px; padding-left: 10px; padding-right: 10px; }
.is-tall .statusbar .long { display: none; }
.is-tall .statusbar .short { display: inline; }
.is-tall .simple-link { height: 28px; }
.is-tall .statusbar .loc-icon { display: none; }
@media (max-width: 480px) { .statusbar { grid-template-columns: auto auto auto; justify-content: space-between; } }
@media (pointer: coarse) {
  .theme-switch { padding: 6px 2px 6px 6px; }
  .theme-switch__track { width: 36px; height: 20px; }
  .theme-switch__track::after { width: 16px; height: 16px; }
  .theme-switch[aria-checked="true"] .theme-switch__track::after { transform: translateX(16px); }
}

/* ---------- 5. Misc ---------- */
.noscript { position: fixed; inset: auto 0 0 0; z-index: 99; margin: 0; padding: 16px; background: var(--accent); color: #111; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: 420ms; }
.theme-fading * { transition: background-color 400ms var(--ease-out), color 400ms var(--ease-out), border-color 400ms var(--ease-out) !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-iteration-count: 1 !important; transition-duration: 1ms !important; }
}

/* Very narrow phones: location moves out of the status bar (it's in Contact) */
@media (max-width: 400px) {
  .status-right .long, .status-right .short { display: none !important; }
  .statusbar { padding-left: 8px; padding-right: 6px; }
}

/* ---------- Sound controls (status bar) ---------- */
.snd { display: inline-flex; align-items: center; gap: 2px; margin-right: 6px; }
.snd__btn {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--frame-text);
  font-size: 12px;
}
.snd__btn:hover { background: color-mix(in srgb, var(--frame-text) 16%, transparent); }
.snd__btn .icon { width: 15px; height: 15px; }
.snd__btn[aria-pressed="false"] { opacity: .6; }
.eq { display: inline-flex; align-items: flex-end; gap: 2px; height: 12px; }
.eq i { width: 2px; height: 3px; border-radius: 1px; background: currentColor; }
.snd__btn--music.is-playing .eq i { animation: eq 1400ms ease-in-out infinite; }
.snd__btn--music.is-playing .eq i:nth-child(2) { animation-delay: -400ms; animation-duration: 1100ms; }
.snd__btn--music.is-playing .eq i:nth-child(3) { animation-delay: -700ms; animation-duration: 1700ms; }
.snd__btn--music.is-playing .eq i:nth-child(4) { animation-delay: -200ms; animation-duration: 1300ms; }
/* Classical | Lo-fi switch */
.snd__style { display: inline-flex; padding: 2px; margin: 0 2px; border-radius: 999px; background: color-mix(in srgb, var(--frame-text) 12%, transparent); }
.snd__style button {
  height: 20px; padding: 0 9px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--frame-text);
  font-size: 11.5px;
}
.snd__style button[aria-checked="true"] { background: var(--field); color: var(--text); }
@media (pointer: coarse) { .snd__style button { height: 30px; padding: 0 10px; } }
@media (max-width: 480px) { .snd__style button { padding: 0 7px; font-size: 11px; } .status-right .loc-icon { display: none; } }
@keyframes eq { 0%, 100% { height: 3px; } 50% { height: 12px; } }
.is-tall .snd__label { display: none; }
@media (pointer: coarse) { .snd__btn { height: 32px; padding: 0 9px; } }

/* ---------- Small touches ---------- */
.theme-switch .icon { transition: transform 600ms cubic-bezier(.3, 1.4, .5, 1), color 300ms; }
.theme-switch[aria-checked="true"] .icon:last-of-type { transform: rotate(90deg) scale(1.15); color: var(--text); }
.theme-switch[aria-checked="false"] .icon:first-of-type { transform: rotate(-20deg) scale(1.1); color: var(--text); }
.status-dot[data-status="available"] { animation: breathe 2.8s ease-in-out infinite; }
@keyframes breathe { 50% { box-shadow: 0 0 0 5px color-mix(in srgb, #3fbf6a 10%, transparent); } }
.simple-btn .icon { transition: transform 260ms cubic-bezier(.3, 1.6, .5, 1); }
.simple-btn:hover .icon { transform: rotate(-10deg) scale(1.12); }

/* Sound controls: inline on larger screens, a small panel on phones */
.snd__toggle { display: none; }
.snd__panel { display: inline-flex; align-items: center; gap: 2px; }
.is-tall .snd { position: relative; }
.is-tall .snd__toggle {
  display: inline-grid; place-items: center;
  width: 36px; height: 32px;
  border: 0; border-radius: 999px;
  background: transparent; color: var(--frame-text);
}
.is-tall .snd__toggle.is-playing .eq i { animation: eq 1400ms ease-in-out infinite; }
.is-tall .snd__toggle.is-playing .eq i:nth-child(2) { animation-delay: -400ms; animation-duration: 1100ms; }
.is-tall .snd__toggle.is-playing .eq i:nth-child(3) { animation-delay: -700ms; animation-duration: 1700ms; }
.is-tall .snd__panel {
  display: none;
  position: absolute; z-index: 60; right: -6px; bottom: calc(100% + 10px);
  flex-direction: column; align-items: stretch; gap: 6px;
  min-width: 180px; padding: 10px;
  border-radius: 14px;
  background: var(--node); border: 1px solid var(--node-edge);
  box-shadow: var(--node-shadow-lift);
}
.is-tall .snd.is-open .snd__panel { display: flex; animation: menu-in 160ms var(--ease-out); }
.is-tall .snd__panel .snd__btn { justify-content: flex-start; height: 38px; padding: 0 12px; color: var(--text); }
.is-tall .snd__panel .snd__label { display: inline; }
.is-tall .snd__panel .snd__style { justify-content: stretch; margin: 0; }
.is-tall .snd__panel .snd__style button { flex: 1; height: 34px; color: var(--text-dim); }
.is-tall .snd__panel .snd__style button[aria-checked="true"] { color: var(--text); }
.is-tall .snd__panel [data-snd="sfx"]::after { content: attr(aria-label); margin-left: 8px; font-size: 12px; }
