/* ————— POSTHASTE · airmail dispatch bureau ————— */

@font-face { font-family: 'Oswald'; src: url('assets/oswald.ttf'); }
@font-face { font-family: 'Work Sans'; src: url('assets/work-sans.ttf'); }
@font-face { font-family: 'IBM Plex Mono'; src: url('assets/ibm-plex-mono.ttf'); font-weight: 400 600; }

:root {
  --ink: #1d2545;            /* deep postal navy ink */
  --ink-soft: #4a4f6b;
  --paper: #f5eedb;          /* desk paper */
  --paper-2: #ece1c4;        /* recessed bay */
  --paper-3: #fdf9ec;        /* letter sheet */
  --blue: #1f3d7a;           /* postal blue */
  --blue-deep: #152a55;
  --air-blue: #2c5aa0;
  --red: #bf372a;            /* stamp red */
  --green: #2e6b46;          /* delivered ink */
  --kraft: #e6c795;
  --kraft-2: #d9b26a;
  --kraft-edge: #a5733a;
  --kraft-ink: #584015;
  --disp: 'Oswald', 'Arial Narrow', sans-serif;
  --sans: 'Work Sans', system-ui, sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(255,252,240,.65), transparent 60%),
    var(--paper);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--blue); color: var(--paper-3); }

/* browser surfaces belong to the bureau too */
input, select, button, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2.5px solid var(--red); outline-offset: 2px; }
* { scrollbar-width: thin; scrollbar-color: var(--blue) var(--paper-2); }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-track { background: var(--paper-2); }
*::-webkit-scrollbar-thumb { background: var(--blue); border: 2px solid var(--paper-2); border-radius: 6px; }

.skip {
  position: absolute; left: -999px; top: 0;
  background: var(--blue-deep); color: var(--paper-3);
  padding: 10px 16px; font-family: var(--mono); font-size: 13px; z-index: 50;
}
.skip:focus { left: 12px; top: 12px; }

.svg-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

/* ————— airmail stripe ————— */
.airmail {
  height: 12px;
  background: repeating-linear-gradient(-45deg,
    var(--blue-deep) 0 14px,
    var(--paper-3) 14px 26px,
    var(--red) 26px 40px,
    var(--paper-3) 40px 52px);
}
.airmail-thin { height: 8px; }

/* ————— masthead ————— */
.masthead { background: var(--blue-deep); color: var(--paper-3); }

.mast-inner {
  max-width: 1240px; margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 40px) 30px;
  display: flex; align-items: center; justify-content: space-between;
  gap: 24px;
}

.mast-lockup { display: flex; align-items: center; gap: 18px; min-width: 0; }

.mast-badge { width: clamp(54px, 6vw, 74px); height: auto; flex: none; }
.badge-ring { fill: none; stroke: var(--paper-3); stroke-width: 2.5; }
.badge-wings { fill: var(--paper-3); }
.badge-env rect { fill: none; stroke: var(--red); stroke-width: 2.5; }
.badge-flap { stroke: var(--red); stroke-width: 2.5; }
.badge-env { transform: translateY(5px); }

.mast-words { min-width: 0; }

.wordmark {
  margin: 0;
  font-family: var(--disp);
  font-weight: 700;
  font-size: clamp(34px, 5vw, 52px);
  line-height: .95;
  letter-spacing: .05em;
  text-transform: uppercase;
}
.wordmark::after { content: "."; color: var(--red); }

.descriptor {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: clamp(11px, 1.3vw, 13px);
  letter-spacing: .32em;
  text-transform: uppercase;
  color: #c8cfe6;
}

/* the round postmark */
.postmark { width: clamp(96px, 10vw, 130px); flex: none; filter: url(#rough-ink-soft); }
.pm-ring { fill: none; stroke: var(--paper-3); stroke-width: 2; }
.pm-ring-2 { stroke-width: 1; opacity: .7; }
.pm-wave { fill: none; stroke: var(--paper-3); stroke-width: 1.6; opacity: .8; }
.pm-arc-top, .pm-date, .pm-year, .pm-count {
  font-family: var(--disp); fill: var(--paper-3);
  text-anchor: middle; text-transform: uppercase; letter-spacing: .12em;
}
.pm-arc-top { font-size: 12px; letter-spacing: .3em; }
.pm-date { font-size: 26px; font-weight: 700; }
.pm-year { font-size: 15px; }
.pm-count { font-family: var(--mono); font-size: 9px; letter-spacing: .18em; fill: #c8cfe6; }

/* ————— desk & controls ————— */
.desk {
  max-width: 1240px; margin: 0 auto;
  padding: 26px clamp(18px, 4vw, 40px) 60px;
}

.controls {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "search filter showing";
  align-items: end; gap: 20px clamp(16px, 3vw, 34px);
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-bottom-width: 3px;
  box-shadow: 7px 9px 18px rgba(29,37,69,.16);
  padding: 18px 22px 20px;
  margin: 0 0 26px;
}

.field { min-width: 0; }
.field-search { grid-area: search; }
.field-filter { grid-area: filter; }

.lbl {
  display: block;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-soft);
  margin: 0 0 6px 2px;
}

.field-search { position: relative; }
.field-search .ico {
  position: absolute; left: 2px; bottom: 11px;
  width: 17px; height: 17px;
  stroke: var(--ink); stroke-width: 2.2; fill: none;
  stroke-linecap: round;
}
.field-search input {
  width: 100%;
  border: 0; border-bottom: 2px solid var(--ink);
  background: transparent;
  font-family: var(--mono); font-size: 15px;
  padding: 8px 6px 9px 28px;
  border-radius: 0;
}
.field-search input::placeholder { color: #8b8fa8; font-family: var(--mono); }
.field-search input:focus-visible { outline: none; border-bottom-color: var(--red); }
.field-search:focus-within .ico { stroke: var(--red); }

.field-filter select,
.status-pick select {
  appearance: none;
  -webkit-appearance: none;
  border: 2px solid var(--ink);
  background:
    linear-gradient(transparent, transparent),
    var(--paper-3);
  background-image:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 L6 6.5 L11 1.5' fill='none' stroke='%231d2545' stroke-width='2'/%3E%3C/svg%3E"),
    linear-gradient(180deg, var(--paper-3), var(--paper-3));
  background-repeat: no-repeat;
  background-position: right 12px center, 0 0;
  background-size: 12px 8px, auto;
  font-family: var(--mono); font-size: 13.5px;
  padding: 9px 34px 9px 12px;
  border-radius: 0;
  cursor: pointer;
  min-width: 200px;
}
select:hover { background-color: #f3ead1; }

.showing {
  grid-area: showing;
  font-family: var(--mono); font-size: 12px;
  color: var(--ink-soft);
  margin: 0 0 10px 2px;
  white-space: nowrap;
}

/* ————— the cabinet ————— */
.cabinet {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}
.cabinet[hidden] { display: none; }

.bay {
  border: 2px solid var(--ink);
  background: var(--paper-2);
  box-shadow: inset 0 3px 8px rgba(29,37,69,.22);
  min-height: 120px;
}

.bay-head {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 14px 9px;
  border-bottom: 2px solid var(--ink);
  color: var(--paper-3);
}
.bay[data-status="todo"] .bay-head { background: var(--blue); }
.bay[data-status="in-progress"] .bay-head { background: var(--air-blue); }
.bay[data-status="blocked"] .bay-head { background: var(--red); }
.bay[data-status="done"] .bay-head { background: var(--green); }

.bay-name {
  font-family: var(--disp); font-weight: 600;
  font-size: 19px; letter-spacing: .09em; text-transform: uppercase;
  margin: 0;
}
.bay-raw {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .12em; opacity: .8;
  margin: 0;
}
.bay-count {
  margin-left: auto;
  font-family: var(--mono); font-size: 12px;
  border: 1.5px solid rgba(245,238,219,.85);
  padding: 1px 8px 0;
  align-self: center;
}

.bay-items { list-style: none; margin: 0; padding: 12px; display: grid; gap: 10px; }

/* kraft mail tag */
.tag {
  position: relative;
  width: 100%;
  display: grid;
  grid-template-columns: 26px 1fr;
  column-gap: 4px;
  text-align: left;
  align-items: start;
  background: linear-gradient(160deg, var(--kraft), var(--kraft-2));
  border: 1.5px solid var(--kraft-edge);
  border-radius: 5px;
  padding: 10px 12px 10px 0;
  cursor: pointer;
  transition: transform .16s ease, box-shadow .16s ease;
}
.tag::before { /* punched hole */
  content: "";
  justify-self: center;
  align-self: start;
  margin-top: 2px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--paper-2);
  border: 1.5px solid rgba(90,60,20,.45);
  box-shadow: inset 0 1px 2px rgba(0,0,0,.25);
}
.tag:hover { transform: translateY(-3px) rotate(-.35deg); box-shadow: 4px 6px 12px rgba(29,37,69,.22); }
.tag:active { transform: translateY(-1px); }

.tag-main { display: block; min-width: 0; }

.tag-wb {
  display: flex; align-items: baseline; gap: 10px;
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .16em; color: var(--kraft-ink);
  margin: 0 0 3px;
}
.tag-prio { margin-left: auto; letter-spacing: .14em; font-weight: 600; }
.tag-prio.prio-high { color: var(--red); }
.tag-prio.prio-low { color: #5f4b1e; font-weight: 400; }

.tag-title {
  display: block;
  margin: 0;
  font-size: 15px; font-weight: 600; line-height: 1.32;
  color: var(--ink);
  overflow-wrap: anywhere;
}

.tag-meta {
  display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 8px;
  margin: 6px 0 0;
  font-family: var(--mono); font-size: 11px; color: var(--kraft-ink);
}
.tag-meta .dot { opacity: .55; }
.tag-project {
  border: 1px solid rgba(90,60,20,.5);
  padding: 0 5px; font-size: 10px; letter-spacing: .08em;
  align-self: center; white-space: nowrap;
}
.tag-notes { display: inline-flex; align-items: center; gap: 4px; }
.tag-notes svg { width: 12px; height: 12px; stroke: var(--kraft-ink); stroke-width: 1.8; fill: none; }

.bay-empty {
  padding: 26px 14px;
  text-align: center;
  font-family: var(--mono); font-size: 12px; letter-spacing: .14em;
  color: #645e3e; text-transform: uppercase;
}
.bay-empty::before { content: "· · ·"; display: block; letter-spacing: .6em; margin-bottom: 6px; }

/* ————— empty state ————— */
.empty {
  border: 2px dashed var(--ink);
  background: var(--paper-3);
  text-align: center;
  padding: 44px 22px 46px;
  margin-top: 4px;
}
.empty[hidden] { display: none; }
.sack { width: 132px; height: auto; margin: 0 auto 6px; display: block; }
.sack-body { fill: var(--kraft-2); stroke: var(--kraft-edge); stroke-width: 2.5; }
.sack-mouth { fill: #4d3413; stroke: var(--kraft-edge); stroke-width: 2.5; }
.sack-twine { fill: none; stroke: #4d3413; stroke-width: 3; }
.sack-seam { stroke: rgba(77,52,19,.5); stroke-width: 2; stroke-linecap: round; }
.empty-title {
  font-family: var(--disp); font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; font-size: 26px; margin: 8px 0 6px;
}
.empty-copy { max-width: 46ch; margin: 0 auto 20px; color: var(--ink-soft); }
.empty-actions { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

.btn {
  font-family: var(--disp); text-transform: uppercase; letter-spacing: .12em;
  font-size: 14px;
  border: 2px solid var(--ink);
  background: var(--paper-3); color: var(--ink);
  padding: 9px 18px 8px;
  cursor: pointer;
  box-shadow: 2px 4px 10px rgba(29,37,69,.18);
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
}
.btn:hover { background: #f0e6cb; transform: translate(-1px, -1px); box-shadow: 3px 5px 12px rgba(29,37,69,.24); }
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 2px 6px rgba(29,37,69,.18); }
.btn-solid { background: var(--blue); color: var(--paper-3); border-color: var(--blue-deep); }
.btn-solid:hover { background: var(--blue-deep); }

/* ————— the letter (detail dialog) ————— */
dialog.letter {
  border: 0;
  padding: clamp(10px, 3vw, 30px);
  background: transparent;
  width: min(760px, 100%);
  max-width: 100%;
  margin: auto;
  color: var(--ink);
}
dialog.letter::backdrop { background: rgba(21,26,50, .58); }

.letter-inner {
  position: relative;
  background: var(--paper-3);
  background-image: repeating-linear-gradient(transparent 0 30px, rgba(31,61,122,.07) 30px 31.5px);
  border: 2px solid var(--ink);
  box-shadow: 12px 16px 34px rgba(10,14,32,.45);
  max-height: calc(100vh - clamp(20px, 6vw, 60px));
  max-height: calc(100dvh - clamp(20px, 6vw, 60px));
  overflow: auto;
  padding: 0 0 26px;
}

.close {
  position: sticky; top: 10px; z-index: 5;
  margin-left: calc(100% - 46px);
  width: 36px; height: 36px;
  display: grid; place-items: center;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 2px 3px 8px rgba(29,37,69,.25);
}
.close svg { width: 13px; height: 13px; stroke: var(--ink); stroke-width: 2.4; stroke-linecap: round; }
.close:hover { background: var(--red); border-color: var(--red); }
.close:hover svg { stroke: var(--paper-3); }

.letter-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 16px;
  padding: 18px 26px 4px;
}
.wb {
  font-family: var(--mono); font-size: 13px;
  letter-spacing: .22em; text-transform: uppercase;
  color: var(--ink-soft);
  margin: 14px 0 0;
}
.letter-postmark { width: 108px; flex: none; filter: url(#rough-ink-soft); margin-top: 0; }
.letter-postmark .pm-ring, .letter-postmark .pm-wave { stroke: var(--ink); }
.letter-postmark text { fill: var(--ink); }
.letter-postmark .pm-count { fill: var(--ink-soft); }
.letter-postmark .pm-date { font-size: 20px; }

.letter-title {
  font-family: var(--disp); font-weight: 700;
  font-size: clamp(24px, 3.4vw, 33px);
  line-height: 1.06;
  letter-spacing: .015em;
  text-transform: uppercase;
  margin: 6px 26px 14px;
  max-width: 22ch;
}

.letter-meta {
  display: flex; flex-wrap: wrap;
  gap: 4px 26px;
  margin: 0 26px 18px;
  padding: 12px 0 10px;
  border-top: 1.5px solid var(--ink);
  border-bottom: 1.5px solid var(--ink);
}
.letter-meta > div { display: flex; align-items: baseline; gap: 7px; }
.letter-meta dt {
  font-family: var(--mono); font-size: 10px;
  letter-spacing: .18em; text-transform: uppercase;
  color: var(--ink-soft);
}
.letter-meta dd { margin: 0; font-family: var(--mono); font-size: 12.5px; font-weight: 600; }
.letter-meta dd.prio-high { color: var(--red); }

.letter-body {
  margin: 0 26px 20px;
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.75;
  max-width: 68ch;
}
.letter-body p { margin: 0 0 1em; }
.letter-body p:last-child { margin-bottom: 0; }
.letter-body strong { font-weight: 600; letter-spacing: .01em; }

.stamp-zone {
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; flex-wrap: wrap;
  margin: 0 26px;
  padding: 18px 16px 14px;
  border-top: 2px dashed rgba(29,37,69,.4);
}

.stamp-slot { min-width: 0; }
.stamp {
  display: inline-block;
  font-family: var(--disp); font-weight: 700;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: .1em; text-transform: uppercase;
  border: 3.5px solid currentColor;
  border-radius: 8px;
  padding: 6px 16px 4px;
  margin: 0;
  transform: rotate(-5deg);
  filter: url(#rough-ink);
  mix-blend-mode: multiply;
}
.stamp[data-status="todo"] { color: var(--blue); }
.stamp[data-status="in-progress"] { color: var(--air-blue); }
.stamp[data-status="blocked"] { color: var(--red); }
.stamp[data-status="done"] { color: var(--green); }

@keyframes stamp-slam {
  0%   { transform: rotate(-14deg) scale(2.4); opacity: 0; }
  55%  { transform: rotate(-4.5deg) scale(.94); opacity: 1; }
  74%  { transform: rotate(-5.5deg) scale(1.04); }
  100% { transform: rotate(-5deg) scale(1); }
}
.stamp.slam { animation: stamp-slam .38s cubic-bezier(.16,.9,.3,1.15); }

.stamp-note {
  font-family: var(--mono); font-size: 10.5px;
  letter-spacing: .16em; text-transform: uppercase;
  color: var(--ink-soft);
  margin: 8px 0 0;
}

.status-pick { min-width: 240px; flex: 1; max-width: 320px; }
.status-pick .lbl { margin-bottom: 7px; }
.status-pick select { width: 100%; min-width: 0; }
.status-hint {
  font-family: var(--mono); font-size: 11px;
  color: var(--ink-soft); margin: 8px 0 0;
}

/* ————— telegram toast ————— */
.telegram {
  position: fixed;
  left: clamp(14px, 3vw, 32px);
  bottom: clamp(14px, 3vw, 28px);
  z-index: 40;
  background: var(--paper-3);
  border: 2px solid var(--ink);
  border-top: 0;
  box-shadow: 6px 8px 18px rgba(10,14,32,.35);
  transform: rotate(-1.2deg);
  min-width: 240px;
  max-width: min(420px, calc(100vw - 28px));
  animation: telegram-in .26s cubic-bezier(.2,.9,.3,1.1);
  cursor: pointer;
}
@keyframes telegram-in {
  from { transform: rotate(-1.2deg) translateY(26px); opacity: 0; }
  to   { transform: rotate(-1.2deg) translateY(0); opacity: 1; }
}
.telegram[hidden] { display: none; }
.telegram-text {
  font-family: var(--mono); font-size: 12.5px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase;
  margin: 0; padding: 10px 14px;
}
.telegram-text b { color: var(--red); }

/* ————— footer ————— */
.foot { margin-top: 30px; }
.foot-line {
  font-family: var(--mono); font-size: 11px;
  letter-spacing: .14em; text-transform: uppercase;
  color: var(--ink-soft);
  text-align: center;
  margin: 0;
  padding: 16px 20px 26px;
}

/* ————— responsive ————— */
@media (max-width: 980px) {
  .controls {
    grid-template-columns: 1fr auto;
    grid-template-areas: "search search" "filter showing";
    align-items: end;
  }
  .cabinet { grid-template-columns: 1fr; }
}

@media (max-width: 640px) {
  .mast-inner { padding: 18px 18px 20px; gap: 12px; }
  .postmark { display: none; }
  .descriptor { letter-spacing: .18em; }
  .controls {
    grid-template-columns: 1fr;
    grid-template-areas: "search" "filter" "showing";
    gap: 14px;
    padding: 14px 16px 16px;
  }
  .field-filter select { width: 100%; }
  .showing { margin: 0; }
  .cabinet { gap: 14px; }
  .bay-items { padding: 10px; gap: 9px; }
  .letter-head { padding: 14px 18px 2px; }
  .letter-postmark { width: 84px; }
  .letter-title { margin: 4px 18px 12px; }
  .letter-meta { margin: 0 18px 16px; }
  .letter-body { margin: 0 18px 18px; font-size: 13px; }
  .stamp-zone { margin: 0 18px; padding: 14px 8px 10px; }
  .telegram { left: 14px; right: 14px; max-width: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
  .tag:hover { transform: none; }
}
