/*
  Wakuya Studio Portal - v1 styling.

  Design tokens below are Yui's real, confirmed values (requirements §7.7
  Decision 1, design/studio-portal-v1-ux.html §00-§01): the portal reuses
  Wakuya's existing dark-ground/copper-accent brand system verbatim - same
  token names and values as design/home-mockup-v7.html and Akane's
  brand-handoff-v8.html, not a separate "internal tool" palette.

  Layout below (2026-10-03 pass) implements her full mockup: left-nav-rail
  app shell (desktop) / hamburger + drawer (mobile, via a checkbox hack -
  no client JS required for the drawer itself), card-based Sprint/Pending
  layouts, a redesigned login screen, and her §08 accessibility checklist
  (skip link, visible focus, prefers-reduced-motion, aria-pressed lang
  toggle - markup for the ARIA/skip-link pieces lives in the view
  templates/partials, this file only carries the corresponding CSS).
*/

/* ---- Self-hosted fonts ----
   4 families copied from the public website's existing self-hosted set
   (website/assets/fonts/, see that file's 2026-09-26 comment for the
   original third-party-request rationale) at the weights currently
   applied below. Noto Sans JP is new for the portal specifically (the
   website correctly dropped it as unused) - content-subsetted rather than
   the full CJK repertoire; see portal/docs/FONTS.md for why and how to
   regenerate it. Linked separately as /css/noto-sans-jp.css (see
   views/partials/head.ejs) rather than @import'ed here - CSS requires
   @import to precede every other rule in the same file, which would force
   reordering this whole file just to accommodate it. */
@font-face {
  font-family: 'Unbounded';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/unbounded-v12-600.woff2') format('woff2');
}
@font-face {
  font-family: 'Big Shoulders Display';
  font-style: normal;
  font-weight: 800;
  font-display: swap;
  src: url('../fonts/big-shoulders-display-v24-800.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-v12-400.woff2') format('woff2');
}
@font-face {
  font-family: 'Plus Jakarta Sans';
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url('../fonts/plus-jakarta-sans-v12-600.woff2') format('woff2');
}
@font-face {
  font-family: 'JetBrains Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url('../fonts/jetbrains-mono-v24-500.woff2') format('woff2');
}

:root {
  /* ---- Brand tokens, carried forward verbatim (Yui §00 Decision 1) ---- */
  --bg: #0B0A08;
  --surface: #16110E;
  --surface-2: #1F1815;
  --border: rgba(240, 205, 180, 0.09);
  --text: #F5EDE6;
  --text-muted: #BFAEA2;
  --text-faint: #908074;
  --accent: #E0A17A;
  --accent-hover: #F2BE9C;
  --accent-deep: #B06A45;
  --on-accent: #1A0E08;
  --seal: #C2352B;
  --seal-ink: #F5EDE6;

  /* ---- Portal-specific semantic tokens, additive only (Yui §01) ---- */
  --input-bg: #1C1511;
  --input-border: #7A6B60; /* Yui S1: was var(--border), about 1.2:1; WCAG 1.4.11 wants 3:1 for the field edge */
  --input-border-focus: var(--accent);
  --error: #E8756A;
  --error-bg: rgba(194, 53, 43, 0.12);
  --error-border: #C2352B;
  --sprint-todo: #A79B90;
  --sprint-progress: #E8C24A;
  --sprint-blocked: #E8756A;
  --sprint-done: #3ECF8E;
  --nav-rail-bg: #0E0B09;
  --nav-active-bg: rgba(224, 161, 122, 0.12);
  --nav-active-text: var(--accent);

  --r-card: 16px;
  --r-btn: 8px;
  --r-chip: 999px;
  --r-input: 8px;

  --font-wordmark: 'Unbounded', ui-sans-serif, sans-serif;
  --font-display: 'Big Shoulders Display', ui-sans-serif, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --font-jp: 'Noto Sans JP', 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

* { box-sizing: border-box; }

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

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
}

/* Yui §07: the active UI language drives the base font - JP running text
   uses Noto Sans JP, EN uses Plus Jakarta Sans. <html lang="..."> is set
   server-side per the active session language (src/i18n/index.js), so
   this takes effect on the very next render along with the language
   switch itself. */
html[lang="ja"] body { font-family: var(--font-jp); }

a { color: var(--accent); }

/* ---- Accessibility: skip link + focus (Yui §08) ---- */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  background: var(--accent);
  color: var(--on-accent);
  padding: 10px 16px;
  border-radius: 0 0 var(--r-btn) 0;
  font-weight: 600;
  text-decoration: none;
}
.skip-link:focus {
  left: 0;
}
a:focus-visible,
button:focus-visible,
input:focus-visible,
.nav-link:focus-visible {
  outline: 2px solid var(--input-border-focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  * { transition-duration: 0.001ms !important; animation-duration: 0.001ms !important; }
}

/* =========================================================================
   App shell: left nav rail (desktop) / hamburger + drawer (mobile)
   ========================================================================= */
.app-shell { display: flex; min-height: 100vh; }

.rail {
  width: 216px;
  flex: none;
  background: var(--nav-rail-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 12px;
}
.rail .brand { display: flex; align-items: center; gap: 9px; padding: 6px 8px 20px; }
.rail .brand .wordmark { font-family: var(--font-wordmark); font-weight: 600; font-size: 12.5px; letter-spacing: 0.03em; color: var(--text); }
.rail nav { display: flex; flex-direction: column; gap: 2px; }
.rail .nav-link { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 8px; color: var(--text-muted); font-size: 13.5px; text-decoration: none; }
html[lang="ja"] .rail .nav-link { font-family: var(--font-jp); }
.rail .nav-link svg { flex: none; opacity: 0.9; }
.rail .nav-link.active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 600; }
.rail .nav-link:hover { background: var(--nav-active-bg); }
.rail .spacer { flex: 1; }
.rail .rail-foot { border-top: 1px solid var(--border); padding-top: 12px; display: flex; flex-direction: column; gap: 10px; }
.rail .user { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); padding: 0 8px; word-break: break-all; }

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(6, 5, 4, 0.5);
}
.topbar .page-title { font-weight: 700; font-size: 15px; }
html[lang="ja"] .topbar .page-title { font-family: var(--font-jp); }
.topbar .right { display: flex; align-items: center; gap: 14px; }
.content { padding: 28px 28px 40px; flex: 1; overflow: auto; }

.logout-form { display: inline; }
.logout-btn {
  font-size: 12.5px;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--r-btn);
  padding: 7px 13px;
  background: none;
  cursor: pointer;
  font-family: inherit;
}
html[lang="ja"] .logout-btn { font-family: var(--font-jp); }
.logout-btn:hover { background: var(--nav-active-bg); }

.signed-in-as { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); }

/* Language toggle: two real <button>s with aria-pressed (Yui §08), not a
   custom unlabeled control. */
.lang-toggle {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: var(--r-chip);
  padding: 3px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  gap: 2px;
}
.lang-toggle button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px 13px;
  border-radius: var(--r-chip);
  color: var(--text-muted);
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
}
.lang-toggle button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

/* Mobile hamburger + drawer, shown only under the breakpoint. Pure-CSS
   toggle via a hidden checkbox - no client JS needed for the drawer
   itself, so it also works unmodified in the static mockup export. */
.mobile-topbar { display: none; }
.nav-toggle-checkbox { position: absolute; opacity: 0; pointer-events: none; }
.burger {
  width: 36px; height: 36px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  cursor: pointer; border-radius: 8px;
}
.burger span { width: 18px; height: 2px; background: var(--text); display: block; }
/* Yui S2 (WCAG 2.4.7): the checkbox is the focusable control and is visually hidden, so ring the burger it drives. */
.nav-toggle-checkbox:focus-visible ~ .mobile-topbar .burger { outline: 2px solid var(--input-border-focus); outline-offset: 2px; }
.drawer {
  display: none;
  background: var(--nav-rail-bg);
  padding: 16px 14px;
  border-bottom: 1px solid var(--border);
}
.drawer nav { display: flex; flex-direction: column; gap: 2px; }
.drawer .nav-link { display: flex; align-items: center; gap: 11px; padding: 11px 10px; border-radius: 8px; color: var(--text-muted); font-size: 14px; text-decoration: none; }
html[lang="ja"] .drawer .nav-link { font-family: var(--font-jp); }
.drawer .nav-link.active { color: var(--nav-active-text); background: var(--nav-active-bg); font-weight: 600; }
.drawer-foot { border-top: 1px solid var(--border); margin-top: 14px; padding-top: 12px; display: flex; justify-content: space-between; align-items: center; }
.nav-toggle-checkbox:checked ~ .drawer { display: block; }

@media (max-width: 860px) {
  /* rc.2: stack the mobile topbar, the drawer and .main vertically. In a
     flex row (the desktop rail layout) they sat side by side, which left a
     ~160px empty column under the topbar at 375px (found during the Y16
     375px check; present since Phase A). */
  .app-shell { flex-direction: column; }
  .rail { display: none; }
  .mobile-topbar {
    display: flex; align-items: center; justify-content: space-between;
    height: 52px; padding: 0 14px; border-bottom: 1px solid var(--border);
    background: var(--surface);
  }
  .mobile-topbar .wordmark { font-family: var(--font-wordmark); font-size: 11px; font-weight: 600; }
  /* The desktop topbar (page title + lang toggle + email + logout) is
     fully replaced by .mobile-topbar + .drawer-foot on mobile, not just
     its title - otherwise the lang toggle/email/logout row still renders
     below the mobile topbar and overflows the narrow viewport. */
  .topbar { display: none; }
  .content { padding: 20px 16px 32px; }
}

/* =========================================================================
   Shared page bits
   ========================================================================= */
.source-note { color: var(--text-muted); font-size: 0.85rem; margin-top: 0; margin-bottom: 24px; }

.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-faint); padding: 10px 14px; border-bottom: 1px solid var(--border); }
html[lang="ja"] .data-table th { font-family: var(--font-jp); }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); }
html[lang="ja"] .data-table td { font-family: var(--font-jp); }
.data-table td.jp { color: var(--text); }
.data-table td.en { color: var(--text-muted); font-family: var(--font-body); }
.role-chip { display: inline-block; max-width: 100%; white-space: normal; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: 11px; color: var(--accent); background: rgba(224, 161, 122, 0.1); border-radius: 12px; padding: 3px 10px; }
.role-desc { display: block; margin-top: 6px; font-size: 12.5px; line-height: 1.6; color: var(--text-muted); }
.data-table td { vertical-align: top; }
.data-table td.en, .data-table td.jp { white-space: nowrap; }
.data-table td.jp { font-family: var(--font-jp); }
.data-table td.role { max-width: 640px; }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 54px 20px; color: var(--text-faint); }
.empty-state .icon { margin-bottom: 14px; opacity: 0.6; }
.empty-state .title { font-size: 14px; color: var(--text-muted); margin-bottom: 4px; font-weight: 600; }
html[lang="ja"] .empty-state .title { font-family: var(--font-jp); }
.empty-state .sub { font-size: 12px; }

.notice { padding: 10px 14px; border-radius: var(--r-btn); font-size: 0.9rem; }
.notice-warn { background: var(--nav-active-bg); color: var(--accent); }
.notice-error { background: var(--error-bg); color: var(--error); border-left: 3px solid var(--error-border); }

/* ---- Sprint card (Yui §05) ---- */
.sprint-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 20px 22px; margin-bottom: 14px; }
.sprint-card .sid { font-family: var(--font-mono); font-size: 11px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.sprint-card h3 { font-size: 16px; margin: 0 0 14px; }
html[lang="ja"] .sprint-card h3 { font-family: var(--font-jp); }
.story-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-top: 1px solid var(--border); gap: 12px; }
.story-row:first-of-type { border-top: none; }
.story-row .story { font-size: 13.5px; }
html[lang="ja"] .story-row .story { font-family: var(--font-jp); }
/* Yui §8.7 Y16 fallback, applied after the 375px check: with the status word
   in front, a flex:none owner cell ran off the card and squeezed the story
   to one word per line. Capped at 45% and allowed to wrap instead. */
.story-row .owner { font-family: var(--font-mono); font-size: 11.5px; color: var(--text-muted); max-width: 45%; text-align: right; overflow-wrap: break-word; }
/* Yui Y18: the owner cell is mono, which has no Japanese glyphs; use the JP face for the status word. */
html[lang="ja"] .story-row .owner { font-family: var(--font-jp); }
.status-word { white-space: nowrap; } /* Yui S3: only a recognised status gets nowrap, so an odd raw status can't overflow the card */
.status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; flex: none; }

/* ---- Pending card (Yui §06) ---- */
.pending-card { background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent-deep); border-radius: 0 12px 12px 0; padding: 18px 20px; margin-bottom: 14px; }
.pending-card .id-chip { display: inline-block; font-size: 0.7rem; font-weight: 700; font-family: var(--font-mono); color: var(--accent); border: 1px solid var(--accent); border-radius: 4px; padding: 1px 6px; margin-bottom: 8px; }
.pending-card .what { font-weight: 700; font-size: 14.5px; margin: 0 0 8px; overflow-wrap: anywhere; }
html[lang="ja"] .pending-card .what { font-family: var(--font-jp); }
.pending-card .detail { font-size: 13px; color: var(--text-muted); line-height: 1.7; margin: 0 0 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.pending-card .detail strong { color: var(--text); font-weight: 600; }
.pending-card .detail code { font-family: var(--font-mono); font-size: 12px; color: var(--text); background: var(--surface-2); border-radius: 4px; padding: 1px 5px; }
html[lang="ja"] .pending-card .detail { font-family: var(--font-jp); }
.pending-card .meta { display: flex; gap: 16px; flex-wrap: wrap; font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); }
.pending-card .meta span { overflow-wrap: anywhere; }

/* =========================================================================
   Login screen (Yui §02)
   ========================================================================= */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; position: relative; background: var(--bg); padding: 48px 20px; }
.login-topbar { position: absolute; top: 24px; right: 24px; }
.login-card { width: 380px; max-width: 92%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-card); padding: 36px 32px 30px; text-align: center; }
.login-card .mark { margin: 0 auto 14px; display: block; }
.login-card h1 { font-weight: 700; font-size: 19px; margin: 0 0 4px; }
html[lang="ja"] .login-card h1 { font-family: var(--font-jp); }
.login-card .sub { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); margin: 0 0 26px; letter-spacing: 0.04em; }

.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; color: var(--text-muted); margin-bottom: 6px; }
html[lang="ja"] .field label { font-family: var(--font-jp); }
.field .input-wrap { position: relative; }
.field input {
  width: 100%;
  background: var(--input-bg);
  color: var(--text);
  border: 1px solid var(--input-border);
  border-radius: var(--r-input);
  padding: 11px 14px;
  font-size: 14px;
  font-family: inherit;
}
.field input:focus { outline: 2px solid var(--input-border-focus); outline-offset: 1px; border-color: var(--input-border-focus); }
.field .eye {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  width: 32px; height: 32px; display: flex; align-items: center; justify-content: center;
  color: var(--text-faint); border-radius: 6px; background: none; border: none; cursor: pointer;
}
.field .eye:hover { background: var(--nav-active-bg); }
.field .eye svg { pointer-events: none; }

.err-banner {
  display: flex; gap: 8px; align-items: flex-start; text-align: left;
  background: var(--error-bg); border-left: 3px solid var(--error-border);
  border-radius: 0 8px 8px 0; padding: 10px 12px; margin-bottom: 16px;
  font-size: 12.5px; color: var(--error); line-height: 1.6;
}
html[lang="ja"] .err-banner { font-family: var(--font-jp); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 600; font-size: 14px; border-radius: var(--r-btn); padding: 11px 20px; text-decoration: none; border: 1px solid transparent; cursor: pointer; font-family: inherit; width: 100%; }
.btn-primary { background: var(--accent); color: var(--on-accent); }
.btn-primary:hover { background: var(--accent-hover); }
html[lang="ja"] .btn { font-family: var(--font-jp); }

.help-text { font-size: 11.5px; color: var(--text-faint); margin-top: 18px; line-height: 1.6; }
html[lang="ja"] .help-text { font-family: var(--font-jp); }

.notice-config {
  margin-top: 16px;
  padding: 10px 12px;
  background: var(--error-bg);
  color: var(--error);
  border-radius: var(--r-btn);
  font-size: 11px;
  text-align: left;
}

/* ---- Phase A additions (Kaito, 2026-10-04). Pending Yui's review. ----
   Replace the v1 inline style="" attributes, so the CSP can be
   style-src 'self' with no 'unsafe-inline', and style the new message,
   step-up and role-label states. Existing tokens only, no new colors. */
.source-note.center { text-align: center; }
.pending-card .meta.meta-urgency { margin-top: 4px; }
.topbar-spacer { display: inline-block; width: 36px; }
.status-dot.dot-todo { background: var(--sprint-todo); }
.status-dot.dot-progress { background: var(--sprint-progress); }
.status-dot.dot-blocked { background: var(--sprint-blocked); }
.status-dot.dot-done { background: var(--sprint-done); }
.rail .user.user-role { color: var(--accent); }
.message-card h1 { margin-bottom: 12px; }
.message-body { font-size: 13.5px; color: var(--text-muted); line-height: 1.7; margin: 0 0 22px; }
html[lang="ja"] .message-body { font-family: var(--font-jp); }
.message-actions { margin: 0; font-size: 13.5px; }
.field input[readonly] { color: var(--text-muted); }
/* Yui §8.7 Y14: account identity in the mobile drawer, same tokens as the rail's .user lines. */
.drawer-foot { flex-wrap: wrap; }
.drawer-foot .drawer-user { flex-basis: 100%; display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.drawer .user { font-family: var(--font-mono); font-size: 11px; color: var(--text-faint); word-break: break-all; }
.drawer .user.user-role { color: var(--accent); }
/* AC-F1 data stamp, in the source-note position (Yui §8.7 Y15). "Unknown" uses the
   .notice-warn accent so it doesn't read as fine print. */
.source-note + .data-stamp { margin-top: -18px; }
.data-stamp code { font-family: var(--font-mono); font-size: 0.8rem; }
.data-stamp-unknown { color: var(--accent); }
/* AC-F2 unavailable banner (Yui Y15): bold title, then body. */
.data-unavailable strong { display: block; }

/* Yui M2 (release record §9): on a phone each Team row becomes one block (name, JP name, then the role chip and
   description at full width). Last in the file, after every .data-table rule. The thead is hidden from sight only. */
@media (max-width: 600px) {
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; }
  .data-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .data-table tr { padding: 14px 0; border-bottom: 1px solid var(--border); }
  .data-table td { border-bottom: 0; padding: 0; }
  .data-table td.en, .data-table td.jp { display: inline-block; }
  .data-table td.en { color: var(--text); font-weight: 600; margin-right: 10px; }
  .data-table td.jp { color: var(--text-muted); }
  .data-table td.role { margin-top: 8px; max-width: none; }
}
