/* ========================================================================
   TEAM HUB STUDIO — DESIGN TOKENS
   All color values live here as custom properties. Nothing below this
   block should ever hardcode a color — reference a variable instead, so
   a brand palette can be dropped in later by editing only this section.
   ======================================================================== */

:root {
  /* --- Color: dark theme (default) --- */
  --bg-canvas: #15130f;          /* near-black, minimal warm cast — avoids reading as "brown" */
  --bg-surface: #211e1a;         /* cards, panels, sidebar */
  --bg-surface-raised: #2b2722;  /* hover states, active nav items */
  --bg-input: #1a1713;           /* form fields */
  --bg-overlay: rgba(10, 9, 7, 0.75);

  --text-primary: #f5f1ea;       /* warm off-white */
  --text-secondary: #c9c0b4;
  --text-muted: #93897c;
  --text-on-accent: #0d211d;

  --border-subtle: #362f28;
  --border-strong: #4a4137;

  --accent: #5fe0ce;             /* vivid, lively teal — carries the "lively" energy */
  --accent-hover: #7ce8d9;
  --accent-muted: rgba(95, 224, 206, 0.14);
  --accent-text: #5fe0ce;        /* 11.5:1 on dark canvas — well above AA */

  --accent-warm: #ff9b6a;        /* vivid warm coral — secondary accent, used sparingly */
  --accent-warm-muted: rgba(255, 155, 106, 0.14);

  --success: #7ad9a0;
  --success-muted: rgba(122, 217, 160, 0.14);
  --danger: #ef8b87;
  --danger-muted: rgba(239, 139, 135, 0.14);

  --locked-bg: #4a3626;
  --locked-border: #6b4d34;
  --locked-text: #f0cda0;

  /* --- Type --- */
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;

  /* --- Layout --- */
  --sidebar-width: 272px;
  --context-panel-width: 264px;
  --topbar-height: 56px;
  --radius-sm: 5px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --gutter-mobile: 12px;
  --gutter-desktop: 20px;

  /* --- Motion --- */
  --ease-standard: cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Color: light theme override --- */
html[data-theme='light'] {
  --bg-canvas: #faf7f2;
  --bg-surface: #ffffff;
  --bg-surface-raised: #f1ece4;
  --bg-input: #ffffff;
  --bg-overlay: rgba(250, 247, 242, 0.72);

  --text-primary: #211d1a;
  --text-secondary: #514a43;
  --text-muted: #837a71;
  --text-on-accent: #ffffff;

  --border-subtle: #e6ded3;
  --border-strong: #d3c8b8;

  --accent: #2f8f84;
  --accent-hover: #267a70;
  --accent-muted: rgba(47, 143, 132, 0.10);
  --accent-text: #1f6a62;        /* darker than --accent — passes AA (5.4:1+) on light backgrounds */

  --accent-warm: #c17a45;
  --accent-warm-muted: rgba(193, 122, 69, 0.12);

  --success: #3f8f5f;
  --success-muted: rgba(63, 143, 95, 0.10);
  --danger: #c1514f;
  --danger-muted: rgba(193, 81, 79, 0.10);

  --locked-bg: #f3e2cd;
  --locked-border: #d8b78c;
  --locked-text: #6b4520;
}

/* ========================================================================
   RESET & BASE
   ======================================================================== */

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

html {
  font-size: 16px; /* accessibility zoom target */
}

body {
  font-family: var(--font-ui);
  background-color: var(--bg-canvas);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

button {
  background: none;
  border: none;
  cursor: pointer;
}

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

/* Visible keyboard focus everywhere */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Optional OCR-A/OCR-B fonts for barcode human-readable text (Tool 15).
   These are typically licensed/commercial fonts — NOT bundled here.
   If you have legal rights to a copy, place the font files at the paths
   below; if absent, the barcode tool falls back to a generic monospace
   font automatically (browsers skip a @font-face rule silently when its
   file is missing, so this is a safe no-op otherwise). */
@font-face {
  font-family: 'OCR-B';
  src: url('lib/fonts/OCR-B.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'OCR-A';
  src: url('lib/fonts/OCR-A.woff2') format('woff2');
  font-display: swap;
}

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

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 6px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ========================================================================
   TOP BAR
   ======================================================================== */

.topbar {
  height: var(--topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--gutter-mobile);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 40;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.topbar-clock {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 84px;
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.05rem;
  color: var(--text-secondary);
  transition: background 0.15s var(--ease-standard);
}
.icon-btn:hover { background: var(--bg-surface-raised); color: var(--text-primary); }

.zoom-control {
  display: flex;
  gap: 2px;
}

.zoom-btn {
  width: 30px;
  height: 30px;
  font-size: 0.72rem;
  font-weight: 700;
  font-family: var(--font-mono);
}

.topbar-brand {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
}

.topbar-brand-suffix {
  display: none;
  color: var(--text-muted);
  font-weight: 500;
}

.topbar-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* ========================================================================
   MAIN LAYOUT
   ======================================================================== */

.app-shell {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ---- Sidebar ---- */

.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: translateX(-100%);
  transition: transform 0.2s var(--ease-standard);
  position: fixed;
  top: var(--topbar-height);
  bottom: 0;
  left: 0;
  z-index: 50;
}

.sidebar.open { transform: translateX(0); }

.sidebar-search {
  padding: 12px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.sidebar-search input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  font-size: 0.83rem;
  color: var(--text-primary);
}
.sidebar-search input::placeholder { color: var(--text-muted); }
.sidebar-search input:focus { border-color: var(--accent); }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 10px 16px;
}

.locked-tools-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--locked-bg);
  border: 1px solid var(--locked-border);
  color: var(--locked-text);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.8rem;
  font-weight: 600;
  margin-bottom: 14px;
  transition: filter 0.15s var(--ease-standard);
}
.locked-tools-link:hover { filter: brightness(1.1); }

.nav-group { margin-bottom: 4px; }

.nav-group-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  padding: 10px 8px 6px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.83rem;
  color: var(--text-secondary);
  transition: background 0.12s var(--ease-standard), color 0.12s var(--ease-standard);
}

.nav-item:hover {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--accent-muted);
  color: var(--text-primary);
  font-weight: 600;
  position: relative;
}
.nav-item.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 20%;
  bottom: 20%;
  width: 3px;
  background: var(--accent);
  border-radius: 2px;
}

.nav-item-num {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  width: 18px;
  flex-shrink: 0;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: var(--topbar-height) 0 0 0;
  background: var(--bg-overlay);
  z-index: 45;
}
.sidebar-backdrop.visible { display: block; }

/* ---- Workspace (main content) ---- */

.workspace {
  flex: 1;
  overflow-y: auto;
  padding: var(--gutter-mobile);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.tool-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tool-eyebrow {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--accent-text);
}

.tool-title {
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tool-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  max-width: 62ch;
  line-height: 1.5;
}

.tool-help {
  font-size: 0.8rem;
  color: var(--text-muted);
  max-width: 62ch;
  line-height: 1.5;
}

/* ---- Dynamic areas ---- */

.dynamic-area {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.dynamic-area-1 {
  /* The hero result. Most visual weight on the page. */
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 10px;
  min-height: 160px;
  background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface-raised) 100%);
}

.result-value {
  font-family: var(--font-mono);
  font-size: 2.1rem;
  font-weight: 500;
  line-height: 1.1;
  word-break: break-word;
}

.result-label {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.dynamic-area-secondary {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.field-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-row label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.field-row input[type='text'],
.field-row input[type='number'],
.field-row textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 9px 11px;
  font-size: 0.86rem;
  width: 100%;
}
.field-row input:focus, .field-row textarea:focus { border-color: var(--accent); }

.field-row input[type='range'] {
  accent-color: var(--accent);
  width: 100%;
}

.field-row input[type='color'] {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
  background: none;
  padding: 2px;
}

/* ---- Buttons (used throughout: export footer, inline actions) ---- */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 14px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background 0.15s var(--ease-standard), filter 0.15s var(--ease-standard);
}

.btn-primary {
  background: var(--accent);
  color: var(--text-on-accent);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--bg-surface-raised);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
}
.btn-secondary:hover { border-color: var(--border-strong); }

.btn-warm {
  background: var(--accent-warm-muted);
  color: var(--accent-warm);
}
.btn-warm:hover { filter: brightness(1.1); }

/* ---- Context panel (right side) ---- */

.context-panel {
  width: var(--context-panel-width);
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  overflow: hidden;
  display: none; /* only shown when a tool populates it */
  flex-direction: column;
}
.context-panel.has-content { display: flex; }

.context-panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.context-panel-export {
  flex-shrink: 0;
  padding: 14px 16px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.context-panel-export .btn {
  width: 100%;
  justify-content: center;
}

.context-widget-title {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ---- Footer ---- */

.app-footer {
  flex-shrink: 0;
  padding: 8px var(--gutter-mobile);
  font-size: 0.72rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  text-align: center;
}

/* ========================================================================
   INTRO OVERLAY
   ======================================================================== */

.intro-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: #eef2f6;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 24px;
  opacity: 1;
  transition: opacity 0.4s var(--ease-standard);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}
.intro-overlay.hidden { opacity: 0; pointer-events: none; }

.intro-card {
  background: #fdfbc9;
  border-radius: 14px;
  padding: 32px 40px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  max-width: 480px;
}

.intro-mark {
  font-family: 'EB Garamond', Garamond, serif;
  font-style: italic;
  font-weight: 700;
  font-size: 1.9rem;
  color: #8a0e6c;
  margin-bottom: 6px;
}
.intro-sub {
  font-size: 0.95rem;
  color: #5b6b7a;
}

.intro-btn {
  position: relative;
  width: 210px;
  height: 48px;
  border-radius: 8px;
  background: #ffffff;
  border: none;
  color: #5b6b7a;
  font-weight: 700;
  font-size: 0.88rem;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.intro-btn.ready {
  background: #8a0e6c;
  color: #ffffff;
  cursor: pointer;
}

.intro-progress {
  position: absolute;
  inset: 0;
  border-radius: 8px;
}
.intro-progress rect {
  fill: none;
  stroke: rgba(255,255,255,0.5);
  stroke-width: 2px;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
}
.intro-btn.running .intro-progress rect {
  transition: stroke-dashoffset linear;
}

.intro-footer-note {
  font-size: 0.78rem;
  color: #5b6b7a;
  margin-top: 12px;
}

/* ========================================================================
   TOAST / ALERT BANNER
   ======================================================================== */

.toast {
  position: fixed;
  top: 12px;
  left: 12px;
  right: 12px;
  z-index: 300;
  background: var(--success-muted);
  color: var(--success);
  border: 1px solid var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  font-weight: 600;
  text-align: center;
  transform: translateY(-80px);
  opacity: 0;
  transition: transform 0.25s var(--ease-standard), opacity 0.25s var(--ease-standard);
}
.toast.visible { transform: translateY(0); opacity: 1; }

/* ========================================================================
   RESPONSIVE — MOBILE (base) vs DESKTOP
   On mobile, the context panel (including the always-visible export
   footer) stacks below the workspace rather than living in a side rail —
   this keeps export/copy actions reachable on every screen size, per
   the "never go hunting for export" requirement.
   ======================================================================== */

.app-shell {
  flex-direction: column;
}

.context-panel {
  width: 100%;
  border-left: none;
  border-top: 1px solid var(--border-subtle);
  max-height: 40vh;
}

@media (min-width: 860px) {
  .topbar { padding: 0 var(--gutter-desktop); }
  .topbar-brand { font-size: 0.9rem; }
  .topbar-brand-suffix { display: inline; }

  .app-shell { flex-direction: row; position: relative; }

  .sidebar {
    position: static;
    transform: none;
    top: auto;
  }
  .sidebar-backdrop { display: none !important; }

  .workspace { padding: var(--gutter-desktop) 28px; }

  .context-panel {
    width: var(--context-panel-width);
    max-height: none;
    border-top: none;
    border-left: 1px solid var(--border-subtle);
  }
  .context-panel.has-content { display: flex; }
}

@media (max-width: 859px) {
  .menu-toggle { display: flex; }
}
@media (min-width: 860px) {
  .menu-toggle { display: none; }
}
