/* ————— Patchbay: the team switchboard ————— */

@font-face { font-family: "Oswald"; src: url("assets/oswald.ttf") format("truetype"); font-weight: 200 700; font-style: normal; font-display: swap; }
@font-face { font-family: "IBM Plex Mono"; src: url("assets/ibm-plex-mono.ttf") format("truetype"); font-weight: 100 800; font-style: normal; font-display: swap; }
@font-face { font-family: "DM Serif Display"; src: url("assets/dm-serif.ttf") format("truetype"); font-weight: 400; font-style: normal; font-display: swap; }

:root {
  color-scheme: dark;
  --felt: #1c2b22;
  --panel: #101c14;
  --paper: #f4e9cf;
  --paper-2: #eadfbf;
  --ink: #2a2117;
  --ink-soft: #6b5c44;
  --brass: #c89b3c;
  --brass-bright: #f2c96b;
  --cream-dim: rgba(244, 233, 207, .55);
  --line: rgba(200, 155, 60, .3);
  --todo: #e0a13c;
  --prog: #5cb771;
  --blocked: #e2543f;
  --done: #8ea2b5;
  --focus: #ffd76a;
}

* { box-sizing: border-box; }

html { scrollbar-color: #5f4a1e #101c14; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 15px;
  line-height: 1.5;
  color: var(--paper);
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(1100px 520px at 50% -8%, rgba(255, 214, 130, .07), transparent 60%),
    radial-gradient(1500px 900px at 50% 115%, rgba(0, 0, 0, .38), transparent 72%),
    var(--felt);
}

body.detail-open { overflow: hidden; }

::selection { background: var(--brass); color: #1b150c; }

h1, h2, h3 { text-wrap: balance; margin: 0; }

button, select, input, a { touch-action: manipulation; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }
.ticket :focus-visible, .card :focus-visible, .empty :focus-visible { outline-color: #8a6410; }

.sr-only, .skip {
  position: absolute; width: 1px; height: 1px; margin: -1px;
  clip-path: inset(50%); overflow: hidden; white-space: nowrap; padding: 0; border: 0;
}
.skip {
  clip-path: none; width: auto; height: auto; margin: 0;
  top: 8px; left: 8px; z-index: 100; padding: 10px 16px;
  background: var(--brass-bright); color: #241c0e; border-radius: 3px;
  font-weight: 700; text-decoration: none;
  transform: translateY(-64px);
  transition: transform .2s ease;
}
.skip:focus { transform: none; }

/* ————— Stage (shifts aside for the call-card panel) ————— */

.stage { transition: margin-right .4s cubic-bezier(.25, .9, .3, 1); }
body.detail-open .stage { margin-right: min(560px, 100vw); }

/* ————— Masthead ————— */

.masthead { border-bottom: 1px solid var(--line); background: rgba(16, 28, 20, .5); }
.masthead-inner {
  max-width: 1280px; margin: 0 auto; padding: 18px 28px;
  display: flex; align-items: center; justify-content: space-between; gap: 18px 28px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.plug { width: 42px; height: 42px; flex: 0 0 auto; }
.wordmark { font-family: "DM Serif Display", serif; font-weight: 400; font-size: 30px; line-height: 1.05; letter-spacing: .01em; color: var(--paper); }
.tagline { margin: 4px 0 0; font-size: 11.5px; color: var(--cream-dim); max-width: 52ch; }

.lampboard { display: flex; flex-wrap: wrap; gap: 8px; }
.lamp-btn {
  display: flex; align-items: center; gap: 8px;
  background: rgba(12, 21, 14, .8);
  border: 1px solid rgba(244, 233, 207, .18);
  color: #d9cfae;
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
  font-family: "Oswald", sans-serif; font-size: 11px; font-weight: 600;
  letter-spacing: .09em; text-transform: uppercase;
  transition: border-color .15s ease, color .15s ease, background-color .15s ease;
}
.lamp-btn:hover { border-color: var(--brass); color: var(--paper); }
.lamp-btn.is-active { background: var(--brass); border-color: var(--brass-bright); color: #241c0e; }
.lamp-count { font-family: "IBM Plex Mono", monospace; font-variant-numeric: tabular-nums; font-size: 12px; }

/* ————— Lamps (status lights) ————— */

.lamp {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%; flex: 0 0 auto;
  border: 2px solid rgba(0, 0, 0, .35);
  box-shadow: inset 0 2px 2px rgba(255, 255, 255, .25), inset -1px -2px 2px rgba(0, 0, 0, .25);
  position: relative;
}
.lamp--todo { background: var(--todo); color: var(--todo); }
.lamp--prog { background: var(--prog); color: var(--prog); }
.lamp--blocked { background: var(--blocked); color: var(--blocked); }
.lamp--done { background: var(--done); color: var(--done); }
.lamp--pulse::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  box-shadow: 0 0 11px 4px currentColor;
  opacity: .15;
  animation: lampPulse 2.4s ease-in-out infinite;
}
@keyframes lampPulse { 0%, 100% { opacity: .12; } 50% { opacity: .85; } }

/* ————— Console (search + filter) ————— */

.console {
  border-bottom: 1px dashed var(--line);
  background: linear-gradient(180deg, rgba(200, 155, 60, .06), rgba(200, 155, 60, .015));
  max-width: 1280px; margin: 0 auto; padding: 16px 28px;
  display: flex; align-items: flex-end; flex-wrap: wrap; gap: 16px 28px;
}
.field { flex: 1 1 240px; min-width: 0; }
.field-filter { flex: 0 1 300px; }
.field label {
  display: block; margin-bottom: 7px;
  font-family: "Oswald", sans-serif; font-size: 11px; font-weight: 600;
  letter-spacing: .16em; text-transform: uppercase; color: var(--brass);
}
.console input, .console select {
  width: 100%;
  background-color: #0c150e; color: var(--paper);
  border: 1px solid #33443a; border-radius: 3px;
  padding: 11px 12px;
  font-family: "IBM Plex Mono", monospace; font-size: 14px;
}
.console input::placeholder { color: rgba(244, 233, 207, .4); }
.console input:hover, .console select:hover { border-color: var(--brass); }
.console input:focus-visible, .console select:focus-visible { border-color: var(--brass); }
.console select {
  appearance: none; padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23c89b3c' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
  cursor: pointer;
}
.count {
  margin: 0 0 2px auto;
  font-size: 12px; color: var(--brass); font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ————— The Cordboard ————— */

main { max-width: 1280px; margin: 0 auto; padding: 26px 28px 10px; }
#board { scroll-margin-top: 24px; }
.section-label {
  display: flex; align-items: center; gap: 10px;
  font-family: "Oswald", sans-serif; font-size: 13px; font-weight: 600;
  letter-spacing: .22em; text-transform: uppercase; color: var(--brass);
  margin: 0 0 22px;
}
.section-label::after { content: ""; flex: 1; height: 1px; background: linear-gradient(90deg, var(--line), transparent); }

.rails { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 24px 22px; align-items: start; }
.rail:only-child { max-width: 660px; }
.rail:only-child .tickets { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 27px 20px; }

.rail-head {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 12px; border-radius: 3px;
  background: linear-gradient(180deg, #8a6d2e, #5f4a1e);
  box-shadow: inset 0 1px 0 rgba(255, 230, 160, .5), 0 2px 5px rgba(0, 0, 0, .45);
  color: #1e1608;
}
.rail-name { font-family: "Oswald", sans-serif; font-size: 12.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
.rail-count { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 12px; font-weight: 700; color: #3a2c0d; }

.tickets { list-style: none; margin: 30px 0 0; padding: 0; display: flex; flex-direction: column; gap: 27px; }

.ticket {
  position: relative;
  background: var(--paper); color: var(--ink);
  border-radius: 2px; padding: 13px 13px 11px;
  transform: rotate(var(--tilt, 0deg));
  box-shadow: 0 1px 0 rgba(0, 0, 0, .35), 0 7px 16px rgba(0, 0, 0, .35);
  transition: transform .18s ease, box-shadow .18s ease;
}
.tickets > .ticket:nth-child(3n+1) { --tilt: -.45deg; }
.tickets > .ticket:nth-child(3n+2) { --tilt: .4deg; }
.tickets > .ticket:nth-child(3n) { --tilt: -.2deg; }
.ticket:hover, .ticket:focus-within {
  transform: translateY(-3px) rotate(0deg);
  box-shadow: 0 2px 0 rgba(0, 0, 0, .35), 0 12px 22px rgba(0, 0, 0, .45);
}
.ticket::before, .ticket::after {
  content: ""; position: absolute; top: 7px; width: 7px; height: 7px; border-radius: 50%;
  background: #101c14; box-shadow: inset 0 1px 2px rgba(0, 0, 0, .7), 0 1px 0 rgba(255, 255, 255, .25);
}
.ticket::before { left: 11px; }
.ticket::after { right: 11px; }

.cord {
  position: absolute; top: -25px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; overflow: visible;
}
.cord path { stroke: var(--cord-c, #6b5a3f); }
.cord-todo { --cord-c: #b07f2c; }
.cord-prog { --cord-c: #3f8a54; }
.cord-blocked { --cord-c: #b13a29; }
.cord-done { --cord-c: #5f7386; }

.t-top { display: flex; align-items: center; gap: 8px; margin: 0 0 3px; }
.t-no { font-size: 10.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-soft); font-weight: 700; white-space: nowrap; }
.t-pri { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; color: var(--ink-soft); }
.t-pri svg { display: block; }

.t-title {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 2px 0 6px; cursor: pointer;
  font-family: "IBM Plex Mono", monospace; font-size: 15px; line-height: 1.35; font-weight: 700;
  color: var(--ink); min-width: 0; overflow-wrap: break-word;
}
.t-title:hover {
  text-decoration: underline; text-decoration-color: var(--brass);
  text-decoration-thickness: 2px; text-underline-offset: 3px;
}
.t-line, .t-who { margin: 0 0 3px; font-size: 12px; color: var(--ink-soft); overflow-wrap: break-word; }
.t-line .t-proj { color: var(--ink); font-weight: 700; }
.t-tags { margin: 7px 0 0; display: flex; flex-wrap: wrap; gap: 5px; }
.chip {
  font-size: 10.5px; letter-spacing: .04em;
  border: 1px solid rgba(90, 79, 61, .55); border-radius: 2px; padding: 1px 7px;
  color: var(--ink-soft); background: rgba(90, 79, 61, .07);
}

.rail-empty {
  list-style: none;
  font-size: 12px; color: var(--cream-dim); text-align: center;
  border: 1px dashed rgba(244, 233, 207, .25); border-radius: 3px;
  padding: 18px 12px;
}

/* ————— Empty state ————— */

.empty {
  max-width: 560px; margin: 34px auto;
  background: rgba(244, 233, 207, .04);
  border: 1px dashed rgba(244, 233, 207, .35); border-radius: 4px;
  padding: 34px 28px; text-align: center;
}
.empty-kicker { margin: 0 0 10px; font-family: "Oswald", sans-serif; font-size: 11px; letter-spacing: .3em; text-transform: uppercase; color: var(--brass); }
.empty h3 { font-family: "DM Serif Display", serif; font-weight: 400; font-size: 24px; margin-bottom: 8px; }
.empty p { margin: 0 auto 18px; font-size: 13px; color: var(--cream-dim); max-width: 44ch; }
.empty-reset {
  font-family: "Oswald", sans-serif; font-size: 12.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  background: var(--brass); color: #241c0e;
  border: 1px solid var(--brass-bright); border-radius: 3px;
  padding: 11px 20px; cursor: pointer;
  transition: background-color .15s ease, transform .15s ease;
}
.empty-reset:hover { background: var(--brass-bright); transform: translateY(-1px); }

/* ————— Call-card panel (detail view) ————— */

.panel {
  position: fixed; inset: 0 0 0 auto;
  width: min(560px, 100vw); height: 100dvh; max-height: none; max-width: none;
  margin: 0; padding: 0; border: 0;
  background:
    radial-gradient(700px 380px at 80% -6%, rgba(255, 214, 130, .05), transparent 60%),
    var(--panel);
  border-left: 1px solid var(--brass);
  box-shadow: -18px 0 44px rgba(0, 0, 0, .5);
  color: var(--paper);
}
.panel[open] { animation: panelIn .32s cubic-bezier(.2, .9, .3, 1); }
@keyframes panelIn { from { transform: translateX(64px); opacity: 0; } to { transform: none; opacity: 1; } }
.panel::backdrop { background: rgba(5, 10, 7, .55); }

.panel-inner {
  height: 100%; overflow-y: auto; overscroll-behavior: contain;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 12px;
}
.panel-bar {
  position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--panel); padding: 6px 2px 10px; margin: 0 -2px;
  border-bottom: 1px solid var(--line);
}
.d-no-line { display: flex; align-items: center; gap: 9px; margin: 0; min-width: 0; }
.d-no { font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--brass); white-space: nowrap; }
.d-line { font-family: "Oswald", sans-serif; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--paper); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.close-btn {
  flex: 0 0 auto;
  background: none; border: 1px solid rgba(244, 233, 207, .35); border-radius: 3px;
  color: var(--paper); padding: 8px 13px; cursor: pointer;
  font-family: "IBM Plex Mono", monospace; font-size: 12.5px;
  transition: background-color .15s ease, color .15s ease, border-color .15s ease;
}
.close-btn:hover { background: var(--brass); border-color: var(--brass-bright); color: #241c0e; }

.panel-cord { display: block; width: 160px; height: 22px; margin: -4px auto 0; }
.panel[open] .panel-cord path {
  stroke-dasharray: 190; stroke-dashoffset: 190;
  animation: drawCord .65s ease-out .1s forwards;
}
@keyframes drawCord { to { stroke-dashoffset: 0; } }

.card {
  position: relative;
  background: var(--paper); color: var(--ink);
  border-radius: 2px; padding: 22px 22px 26px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .5);
}
.d-title {
  font-family: "DM Serif Display", serif; font-weight: 400;
  font-size: 25px; line-height: 1.18; color: var(--ink);
  margin: 2px 0 16px; text-wrap: pretty;
}
.d-meta {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px;
  margin: 0 0 16px; padding: 14px 0;
  border-top: 2px dashed rgba(90, 79, 61, .35);
  border-bottom: 2px dashed rgba(90, 79, 61, .35);
}
.d-meta div { min-width: 0; }
.d-meta dt {
  font-family: "Oswald", sans-serif; font-size: 10px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
  margin-bottom: 2px;
}
.d-meta dd { margin: 0; font-size: 13.5px; font-weight: 700; overflow-wrap: break-word; }

.d-status {
  border: 1px solid rgba(90, 79, 61, .4); border-radius: 3px;
  background: rgba(200, 155, 60, .08);
  padding: 13px 14px; margin-bottom: 18px;
}
.d-status label {
  display: block; margin-bottom: 7px;
  font-family: "Oswald", sans-serif; font-size: 10.5px; font-weight: 600;
  letter-spacing: .14em; text-transform: uppercase; color: var(--ink-soft);
}
.paper-select {
  width: 100%;
  background-color: var(--paper-2); color: var(--ink);
  border: 1px solid #8a7a58; border-radius: 3px;
  padding: 10px 12px; padding-right: 34px;
  font-family: "IBM Plex Mono", monospace; font-size: 14px;
  appearance: none; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%232a2117' stroke-width='2'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center;
}
.paper-select:hover { border-color: var(--ink); }
.d-now {
  display: flex; align-items: center; gap: 8px;
  margin: 10px 0 0; font-size: 12.5px; color: var(--ink-soft);
}

.d-body { font-size: 14px; line-height: 1.7; }
.d-body p { margin: 0 0 12px; overflow-wrap: break-word; }
.d-body .outcome {
  border-left: 3px solid var(--brass);
  background: rgba(200, 155, 60, .12);
  padding: 10px 12px; border-radius: 0 3px 3px 0;
}
.d-tags { display: flex; flex-wrap: wrap; gap: 5px; margin: 4px 0 0; }

.stamp {
  position: absolute; top: 58px; right: 14px;
  transform: rotate(-9deg);
  border: 3px solid currentColor; border-radius: 6px;
  padding: 5px 14px 4px;
  font-family: "Oswald", sans-serif; font-size: 21px; font-weight: 700;
  letter-spacing: .12em; text-transform: uppercase;
  opacity: 0; pointer-events: none;
  mix-blend-mode: multiply;
  transition: opacity .45s ease;
}
.st-todo { color: var(--todo); }
.st-prog { color: var(--prog); }
.st-blocked { color: var(--blocked); }
.st-done { color: #5f7386; }
.stamp.show { animation: stampIn .45s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes stampIn {
  from { opacity: 0; transform: rotate(-9deg) scale(1.7); }
  60% { opacity: 1; transform: rotate(-9deg) scale(.94); }
  to { opacity: 1; transform: rotate(-9deg) scale(1); }
}
.stamp.fade { opacity: 0; }

/* ————— Toast (paper slip inside the call-card panel) ————— */

.toast {
  position: absolute; left: 18px; bottom: max(18px, env(safe-area-inset-bottom));
  z-index: 5;
  display: flex; align-items: center; gap: 9px;
  max-width: calc(100% - 36px);
  background: var(--paper); color: var(--ink);
  border-radius: 2px; padding: 10px 14px;
  font-size: 12.5px; line-height: 1.4;
  box-shadow: 0 10px 26px rgba(0, 0, 0, .5);
  border-left: 4px solid var(--brass);
  transform: translateY(16px); opacity: 0; pointer-events: none;
  transition: transform .3s ease, opacity .3s ease;
}
.toast.show { transform: none; opacity: 1; }

/* ————— Colophon ————— */

.colophon {
  max-width: 1280px; margin: 0 auto; padding: 22px 28px;
  font-size: 11px; color: var(--cream-dim);
  border-top: 1px solid rgba(200, 155, 60, .18);
}

/* ————— Small screens ————— */

@media (max-width: 760px) {
  body.detail-open .stage { margin-right: 0; }
  .masthead-inner { padding: 14px 16px; }
  .wordmark { font-size: 24px; }
  .plug { width: 34px; height: 34px; }
  .tagline { font-size: 10.5px; }
  .lamp-btn { padding: 7px 9px; }
  .console { padding: 14px 16px; }
  main { padding: 20px 16px 10px; }
  .rails { grid-template-columns: 1fr; }
  .count { margin-left: 0; width: 100%; }
  .colophon { padding: 16px; text-align: center; }
}

@media (max-width: 460px) {
  .d-meta { grid-template-columns: 1fr; }
  .d-title { font-size: 21px; }
  .panel-inner { padding: 10px 12px calc(20px + env(safe-area-inset-bottom)); }
  .card { padding: 18px 15px 22px; }
  .stamp { font-size: 16px; top: 46px; right: 8px; }
}

/* ————— Reduced motion ————— */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .lamp--pulse::after { animation: none; opacity: .3; }
  .panel[open] .panel-cord path { stroke-dashoffset: 0; animation: none; }
}
