/* ============================================================
   davides.net — two palettes:
   Paper   = the main site (warm paper, ink, violet)
   Archive = earlier work (black, white, the old portfolio's green)
   ============================================================ */
:root,
html[data-theme="paper"] {
  --bg: #f3f1ea;
  --fg: #111111;
  --wall: #5227ff;
  --accent: #5227ff;
  --muted: rgba(17, 17, 17, 0.6);
  --soft: rgba(17, 17, 17, 0.84);
  --line: rgba(17, 17, 17, 0.12);
  --panel: rgba(243, 241, 234, 0.82);
  --frame: rgba(17, 17, 17, 0.035);
}
html[data-theme="archive"] {
  --bg: #000000;
  --fg: #f2fff6;
  --wall: #3dff8a;
  --accent: #3dff8a;
  --muted: rgba(242, 255, 246, 0.6);
  --soft: rgba(242, 255, 246, 0.84);
  --line: rgba(242, 255, 246, 0.14);
  --panel: rgba(0, 0, 0, 0.72);
  --frame: rgba(61, 255, 138, 0.04);
}

:root {
  --sans: "Inter", "Noto Sans JP", "Hiragino Sans", "Yu Gothic", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", "M PLUS 1 Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
  --gutter: clamp(16px, 3vw, 28px);
}
html[lang="ja"] { --sans: "Noto Sans JP", "Inter", "Hiragino Sans", "Yu Gothic", system-ui, sans-serif; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color .4s ease;
}
a { color: inherit; }
button { font: inherit; color: inherit; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Wall stage ---------- */
#stage { position: fixed; inset: 0; }
#wall { display: block; width: 100%; height: 100%; touch-action: pan-x; }

.mark, .archive-intro {
  position: absolute; top: var(--gutter); left: var(--gutter);
  margin: 0; pointer-events: none;
  transition: opacity .35s ease;
}
.mark p { margin: 0; font: 500 12px/1.5 var(--mono); letter-spacing: .08em; }
.mark-role { color: var(--muted); }
.archive-intro { max-width: min(420px, calc(100vw - 2 * var(--gutter) - 150px)); }
.archive-intro .eyebrow { margin: 0 0 8px; font: 500 11px/1.4 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
.archive-text { margin: 0; font-size: 13px; line-height: 1.6; color: var(--muted); }

html[data-theme="paper"] .archive-intro,
html[data-theme="archive"] .mark { opacity: 0; visibility: hidden; }

/* arrows between the main menu and the archive */
.arrow {
  position: absolute; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  background: none; border: 0; padding: 8px 12px; cursor: pointer;
  transition: opacity .35s ease;
}
.arrow-down { bottom: max(18px, env(safe-area-inset-bottom)); }
.arrow-up { top: 18px; }
.arrow-icon {
  display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--panel);
  font: 500 16px/1 var(--mono); color: var(--accent);
  transition: border-color .2s ease, transform .3s var(--ease);
}
.arrow-label { font: 500 10.5px/1 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.arrow:hover .arrow-icon, .arrow:focus-visible .arrow-icon { border-color: var(--accent); }
.arrow-down:hover .arrow-icon { transform: translateY(3px); }
.arrow-up:hover .arrow-icon { transform: translateY(-3px); }
.arrow-down .arrow-icon { animation: nudge-down 2.6s ease-in-out 3s infinite; }
@keyframes nudge-down { 0%, 70%, 100% { transform: none; } 80% { transform: translateY(4px); } 90% { transform: translateY(0); } }
html[data-theme="paper"] .arrow-up,
html[data-theme="archive"] .arrow-down { opacity: 0; visibility: hidden; }

/* ---------- Language switch ---------- */
.lang {
  position: fixed; z-index: 30; top: var(--gutter); right: var(--gutter);
  display: flex; align-items: center; gap: 2px; padding: 3px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--panel);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}
.lang button {
  border: 0; background: none; cursor: pointer; padding: 6px 10px; border-radius: 999px;
  font: 500 11px/1 var(--mono); letter-spacing: .14em; color: var(--muted);
  transition: color .2s ease, background-color .2s ease;
}
.lang button:hover { color: var(--fg); }
.lang button[aria-pressed="true"] { color: var(--bg); background: var(--fg); }

/* ---------- Curtain (main menu <-> archive) ---------- */
#curtain {
  position: fixed; inset: 0; z-index: 40; pointer-events: none;
  transform: translateY(100%); will-change: transform;
}

/* ---------- Intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 50; background: var(--bg); outline: none; cursor: default;
  font-family: var(--sans);
  transition: opacity .9s ease;
}
#intro[hidden] { display: none; }
#introText { position: absolute; inset: 0; transition: opacity .6s ease; }
#introText canvas { display: block; width: 100%; height: 100%; } /* from Tech Text's own stylesheet */
#introText.tech-text { user-select: none; touch-action: pan-y; }
#intro.fading #introText { opacity: 0; }
#intro.gone { opacity: 0; pointer-events: none; }

/* ---------- NDA gate ---------- */
#gate {
  position: fixed; inset: 0; z-index: 22; display: grid; place-items: center; padding: 24px;
  pointer-events: none; opacity: 0; transition: opacity .45s ease;
}
#gate[hidden] { display: none; }
#gate.show { opacity: 1; }
#gate .back, #gateForm { pointer-events: auto; }
body.gate-open .mark, body.gate-open .archive-intro, body.gate-open .arrow { opacity: 0; visibility: hidden; }
#gateForm {
  width: min(440px, 100%); padding: 14px 28px 11px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-radius: 6px;
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  transition: transform .7s var(--ease), opacity .6s ease, filter .6s ease;
}
#gateForm::before, #gateForm::after { content: ""; position: absolute; width: 5px; height: 5px; background: var(--accent); top: -3px; }
#gateForm { position: relative; }
#gateForm::before { left: -3px; } #gateForm::after { right: -3px; }
.gate-eyebrow { margin: 0 0 14px; font: 500 11px/1.4 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--accent); }
#gateTitle { margin: 0 0 10px; font-size: clamp(24px, 3.2vw, 34px); font-weight: 500; letter-spacing: -0.025em; line-height: 1.15; }
.gate-text { margin: 0 auto 22px; max-width: 34ch; font-size: 14px; line-height: 1.6; color: var(--muted); }
.gate-field { display: flex; align-items: stretch; border-bottom: 1px solid var(--fg); }
#gateInput {
  flex: 1; min-width: 0; border: 0; background: none; outline: none; color: var(--fg);
  padding: 12px 4px; font: 500 16px/1.2 var(--mono); letter-spacing: .14em; text-align: center; caret-color: var(--accent);
}
#gateInput::placeholder { color: var(--muted); letter-spacing: .2em; text-transform: uppercase; font-size: 12px; }
#gateSubmit {
  border: 0; background: none; cursor: pointer; padding: 0 6px 0 12px; color: var(--accent);
  font: 500 18px/1 var(--mono); transition: transform .25s ease;
}
#gateSubmit:hover, #gateSubmit:focus-visible { transform: translateX(3px); outline: none; }
.gate-field:focus-within { border-bottom-color: var(--accent); }
.gate-msg { min-height: 1.6em; margin: 6px 0 0; font: 400 12px/1.6 var(--mono); color: var(--muted); }
#gate.busy #gateInput { opacity: .5; }
#gate.busy .gate-msg { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .4; } }
#gateForm.shake { animation: shake .42s cubic-bezier(.36,.07,.19,.97); }
#gateForm.shake .gate-msg { color: var(--accent); }
@keyframes shake { 15%, 85% { transform: translateX(-2px); } 30%, 70% { transform: translateX(5px); } 45%, 55% { transform: translateX(-8px); } 50% { transform: translateX(8px); } }
/* correct password: the form dissolves, then the case study fades in */
#gate.opening #gateForm { opacity: 0; transform: scale(.97); filter: blur(4px); }

/* ---------- Pages (case studies, About, Contact) ---------- */
.page {
  position: fixed; inset: 0; z-index: 20; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); color: var(--fg);
  opacity: 0; transition: opacity .45s ease;
}
.page[hidden] { display: none; }
.page.show { opacity: 1; }
.page .pg { transform: translateY(14px); transition: transform .6s var(--ease); }
.page.show .pg { transform: none; }

.back {
  position: fixed; z-index: 25; top: var(--gutter); left: var(--gutter);
  display: inline-flex; align-items: center; gap: 10px; padding: 9px 14px 9px 12px;
  font: 500 12px/1 var(--mono); letter-spacing: .14em; text-transform: uppercase; text-decoration: none;
  color: var(--fg); background: var(--panel);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 999px; transition: border-color .2s ease;
}
.back-arrow { color: var(--accent); display: inline-block; transition: transform .25s ease; }
.back:hover, .back:focus-visible { border-color: var(--accent); outline: none; }
.back:hover .back-arrow, .back:focus-visible .back-arrow { transform: translateX(-4px); }

.pg { max-width: 1120px; margin: 0 auto; padding: 128px 32px 88px; }
.pg-eyebrow { margin: 0 0 22px; font: 500 11px/1.4 var(--mono); letter-spacing: .24em; text-transform: uppercase; color: var(--accent); }
.pg-eyebrow span { color: var(--muted); }
.pg h1 {
  margin: 0 0 26px; max-width: 15ch;
  font-size: clamp(38px, 6.2vw, 82px); font-weight: 500; letter-spacing: -0.035em; line-height: 1.02;
}
/* Signal Type titles: an unlit hairline tube, then lit letters with a halo in the accent colour */
html[data-theme="paper"] { --glow-a: 36%; --glow-b: 18%; --glow-flash: 70%; }
html[data-theme="archive"] { --glow-a: 60%; --glow-b: 32%; --glow-flash: 90%; }
.sig { cursor: default; }
.sig-w { display: inline-block; white-space: nowrap; }
.sig-l {
  color: transparent;
  -webkit-text-stroke: 1px color-mix(in srgb, var(--fg) 28%, transparent);
}
.sig-l.on {
  color: var(--fg);
  -webkit-text-stroke-color: transparent;
  text-shadow: 0 0 .1em color-mix(in srgb, var(--accent) var(--glow-a), transparent), 0 0 .45em color-mix(in srgb, var(--accent) var(--glow-b), transparent);
}
.sig-l.on.flash {
  text-shadow: 0 0 .08em var(--accent), 0 0 .5em color-mix(in srgb, var(--accent) var(--glow-flash), transparent), 0 0 1.1em color-mix(in srgb, var(--accent) var(--glow-b), transparent);
}
html[lang="ja"] .pg h1 { letter-spacing: -0.01em; line-height: 1.18; max-width: 14em; font-size: clamp(32px, 5vw, 64px); }
.pg-lede { margin: 0 0 48px; max-width: 58ch; font-size: clamp(17px, 1.6vw, 21px); line-height: 1.55; color: var(--muted); }
.pg-meta { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0 0 64px; border-top: 1px solid var(--line); }
.pg-meta div { padding: 16px 16px 0 0; }
.pg-meta dt { margin-bottom: 6px; font: 500 10.5px/1.4 var(--mono); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.pg-meta dd { margin: 0; font-size: 15px; line-height: 1.45; }
/* longer project details: one row per item, label on the left */
.pg-meta.rows { grid-template-columns: 1fr; max-width: 920px; }
.pg-meta.rows div { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 24px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.pg-meta.rows dt { margin: 0; padding-top: 4px; }

/* tables inside a case study */
.pg-body .pg-table { margin: 36px 0 40px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.pg-body table { width: 100%; min-width: 540px; border-collapse: collapse; font-size: 15px; line-height: 1.5; }
.pg-body th, .pg-body td { padding: 12px 18px 12px 0; text-align: left; vertical-align: top; border-top: 1px solid var(--line); }
.pg-body thead th { padding: 0 18px 10px 0; border-top: 0; font: 500 10.5px/1.45 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.pg-body thead th strong { color: inherit; font-weight: 500; }
.pg-body thead th:last-child { color: var(--accent); }
.pg-body tbody th { width: 24%; font-weight: 500; color: var(--fg); }
.pg-body td { color: var(--soft); }
.pg-body tbody tr:last-child > * { border-bottom: 1px solid var(--line); }
html[lang="ja"] .pg-body table { font-size: 14px; line-height: 1.7; }

.fig { position: relative; margin: 0; border: 1px solid var(--line); border-radius: 4px; background: var(--frame); }
.fig img, .fig video { display: block; width: 100%; height: auto; border-radius: 3px; }
.fig .vimeo { position: relative; width: 100%; }
.fig .vimeo iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 3px; }
.fig::before, .fig::after, .fig i.c3, .fig i.c4 {
  content: ""; position: absolute; width: 5px; height: 5px; background: var(--accent); opacity: .9;
}
.fig::before { top: -3px; left: -3px; } .fig::after { top: -3px; right: -3px; }
.fig i.c3 { bottom: -3px; left: -3px; } .fig i.c4 { bottom: -3px; right: -3px; }
.fig .fig-label {
  position: absolute; top: -22px; left: 0; white-space: nowrap;
  font: 500 10.5px/1 var(--mono); color: var(--accent); opacity: .8;
}
.fig figcaption.fig-cap { padding: 10px 12px 12px; font-size: 13px; line-height: 1.5; color: var(--muted); }
.fig.narrow { max-width: 520px; }
.fig.portrait { max-width: 440px; }
.pg-hero { margin-bottom: 104px; }
.pg-hero.portrait { width: fit-content; max-width: 100%; }
.pg-hero.portrait img, .pg-hero.portrait video { width: auto; max-width: 100%; max-height: 74vh; }
.pg-hero .vimeo { max-height: 74vh; }

.pg-sec { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 48px; padding: 56px 0; border-top: 1px solid var(--line); }
.pg-sec-label { position: sticky; top: 96px; align-self: start; }
.pg-num { display: block; margin-bottom: 10px; font: 500 12px/1 var(--mono); letter-spacing: .1em; color: var(--accent); }
.pg-sec h2 { margin: 0; font-size: 24px; font-weight: 500; letter-spacing: -0.02em; line-height: 1.25; }
.pg-body { max-width: 66ch; min-width: 0; }
.pg-body p, .pg-body li { font-size: 17px; line-height: 1.75; color: var(--soft); }
html[lang="ja"] .pg-body p, html[lang="ja"] .pg-body li { font-size: 16px; line-height: 1.95; }
.pg-body p { margin: 0 0 20px; }
.pg-body strong { color: var(--fg); font-weight: 600; }
.pg-body a { text-decoration: none; border-bottom: 1px solid var(--accent); }
.pg-body h3 { margin: 40px 0 14px; font: 500 12px/1.4 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--accent); }
.pg-body h3:first-child { margin-top: 0; }
.pg-body ul { list-style: none; margin: 0 0 24px; padding: 0; }
.pg-body li { position: relative; padding: 0 0 12px 30px; }
.pg-body li::before { content: attr(data-n); position: absolute; left: 0; top: 5px; font: 500 11px/1 var(--mono); color: var(--accent); }
.pg-body .fig { margin: 44px 0 40px; }
.pg-body blockquote {
  margin: 8px 0 28px; padding: 0 0 0 20px; border-left: 2px solid var(--accent);
  font-size: 19px; line-height: 1.6; color: var(--fg);
}
.pg-body .grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin: 44px 0 40px; }
.pg-body .grid2 .fig { margin: 0; }
.pg-body .note { font: 400 12.5px/1.6 var(--mono); color: var(--muted); }

.pg-links { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 24px; }
.pg-links a {
  display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  font: 500 12px/1 var(--mono); letter-spacing: .08em; text-decoration: none; border-bottom: 1px solid var(--line);
}
.pg-links a:hover { border-color: var(--accent); }

.pg-next {
  display: block; margin-top: 24px; padding: 40px 0 8px; border-top: 1px solid var(--line); text-decoration: none;
}
.pg-next small { display: block; margin-bottom: 10px; font: 500 11px/1 var(--mono); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.pg-next span { font-size: clamp(26px, 3.6vw, 44px); font-weight: 500; letter-spacing: -0.03em; }
.pg-next span::after { content: " →"; color: var(--accent); transition: margin .25s ease; }
.pg-next:hover span::after { margin-left: 8px; }
.pg-foot {
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--line);
  font: 500 11px/1.6 var(--mono); letter-spacing: .14em; text-transform: uppercase; color: var(--muted);
}

/* About */
.about-photos { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin: 0 0 96px; }
.about-photos .fig { margin: 0; }
.about-photos img { aspect-ratio: 3 / 4; object-fit: cover; }
.about-photos .fig-cap { display: none; }

/* Contact */
.contact-list { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.contact-list li { border-bottom: 1px solid var(--line); }
.contact-list a {
  display: flex; justify-content: space-between; align-items: baseline; gap: 16px; padding: 26px 0;
  text-decoration: none; transition: padding .3s var(--ease);
}
.contact-list a:hover { padding-left: 10px; }
.contact-list .c-name { font-size: clamp(28px, 4.4vw, 56px); font-weight: 500; letter-spacing: -0.03em; }
.contact-list .c-name::after { content: " ↗"; color: var(--accent); font-size: .6em; vertical-align: .3em; }
.contact-list .c-handle { font: 500 12px/1.4 var(--mono); letter-spacing: .08em; color: var(--muted); text-align: right; overflow-wrap: anywhere; }

.noscript { position: fixed; inset: 0; z-index: 99; padding: 32px; background: var(--bg); font: 16px/1.6 var(--sans); }

/* ---------- Small screens ---------- */
@media (max-width: 820px) {
  .pg { padding: 104px 20px 64px; }
  .pg-meta { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pg-sec { grid-template-columns: 1fr; gap: 18px; padding: 44px 0; }
  .pg-sec-label { position: static; }
  .pg-body .grid2 { grid-template-columns: 1fr; }
  .about-photos { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .lang button { padding: 6px 8px; letter-spacing: .1em; }
  .archive-intro { max-width: calc(100vw - 2 * var(--gutter) - 130px); }
  .archive-text { display: none; }
  .arrow-label { display: none; }
  .contact-list a { flex-direction: column; gap: 6px; }
  .contact-list .c-handle { text-align: left; }
  .pg-meta.rows div { grid-template-columns: 1fr; gap: 6px; }
  /* tables become one block per row */
  .pg-body table { min-width: 0; }
  .pg-body table, .pg-body tbody, .pg-body tr { display: block; }
  .pg-body thead { display: none; }
  .pg-body tbody tr { padding: 14px 0 6px; border-top: 1px solid var(--line); }
  .pg-body tbody tr:last-child { border-bottom: 1px solid var(--line); }
  .pg-body tbody tr:last-child > * { border-bottom: 0; }
  .pg-body tbody th { display: block; width: auto; padding: 0 0 8px; border: 0; }
  .pg-body td { display: grid; grid-template-columns: minmax(0, 42%) minmax(0, 1fr); gap: 12px; padding: 0 0 8px; border: 0; }
  .pg-body td::before { content: attr(data-label); font: 500 10px/1.6 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); padding-top: 2px; }
  .pg-body td:last-child { color: var(--fg); }
  .pg-body td:last-child::before { color: var(--accent); }
  .pg-meta.rows dt { padding-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
}
