/* ============================================================
   STACKS — a card-catalog themed team task inbox
   ============================================================ */

:root {
  color-scheme: light;

  --wood-dark: #3c2415;
  --wood: #5a3620;
  --wood-light: #79512f;
  --wood-grain: #6b4426;

  --paper: #f4ecd8;
  --paper-shadow: #e2d4ac;
  --paper-line: #d8c495;
  --ink: #2b2115;
  --ink-soft: #52432f;

  --brass: #cda85e;
  --brass-dark: #9c7a3c;
  --brass-light: #e6c988;

  --status-todo: #2f5a86;
  --status-inprogress: #8a5a12;
  --status-blocked: #8a2f20;
  --status-done: #2f6b3f;

  --priority-high: #a13d2b;
  --priority-medium: #c98a2c;
  --priority-low: #4c7a52;

  --focus-ring: #1c63d1;
  --radius-card: 3px;

  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    repeating-linear-gradient(
      transparent,
      transparent 27px,
      rgba(43, 33, 21, 0.05) 28px
    ),
    var(--wood);
  background-color: var(--wood);
  font-family: "Courier New", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color: var(--ink);
  overscroll-behavior-y: contain;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 0;
  background: var(--brass-light);
  color: var(--wood-dark);
  padding: 0.75rem 1rem;
  z-index: 100;
  font-weight: 700;
  border-radius: 0 0 6px 0;
}

.skip-link:focus-visible {
  left: 0;
}

button {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* -------------------- focus -------------------- */

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

/* -------------------- header -------------------- */

.cabinet-header {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0) 40%),
    repeating-linear-gradient(
      90deg,
      var(--wood-dark) 0px,
      var(--wood-grain) 3px,
      var(--wood-dark) 60px
    );
  padding: 2rem 1.5rem 2.25rem;
  border-bottom: 10px solid var(--wood-dark);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.35);
}

.brass-plate {
  max-width: 46rem;
  margin: 0 auto;
  background: linear-gradient(180deg, var(--brass-light), var(--brass) 60%, var(--brass-dark));
  border: 2px solid var(--brass-dark);
  border-radius: 6px;
  padding: 1.1rem 1.5rem 1.3rem;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 4px 10px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.plate-eyebrow {
  margin: 0 0 0.15rem;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  font-size: 0.8rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--wood-dark);
  opacity: 0.75;
}

.plate-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 700;
  font-size: clamp(2rem, 5vw, 2.75rem);
  letter-spacing: 0.12em;
  color: var(--wood-dark);
  text-wrap: balance;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.tagline {
  margin: 0.5rem auto 0;
  max-width: 34rem;
  font-size: 0.92rem;
  color: var(--wood-dark);
  line-height: 1.45;
}

/* -------------------- main layout -------------------- */

main {
  max-width: 68rem;
  margin: 0 auto;
  padding: 1.75rem 1.25rem 4rem;
}

.lookup-bar {
  display: grid;
  grid-template-columns: 1fr 14rem;
  gap: 1rem;
  align-items: end;
  margin-bottom: 1.1rem;
}

.lookup-slip,
.drawer-select-wrap {
  background: var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-card);
  padding: 0.65rem 0.85rem 0.75rem;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.25);
}

.lookup-slip label,
.drawer-select-wrap label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  margin-bottom: 0.3rem;
  font-family: Georgia, "Times New Roman", serif;
}

.lookup-slip input,
.drawer-select-wrap select {
  width: 100%;
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--paper-line);
  border-bottom: 2px solid var(--ink-soft);
  border-radius: 2px;
  background: #fffdf6;
  color: var(--ink);
}

.drawer-select-wrap select {
  color-scheme: light;
  background-color: #fffdf6;
  cursor: pointer;
}

/* quick drawer-front navigation */

.drawer-fronts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1.1rem;
}

.drawer-front {
  flex: 1 1 9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font: inherit;
  font-size: 0.85rem;
  color: var(--paper);
  background: linear-gradient(180deg, var(--wood-light), var(--wood));
  border: 1px solid var(--wood-dark);
  border-bottom: 3px solid var(--wood-dark);
  border-radius: 3px;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.drawer-front:hover {
  background: linear-gradient(180deg, #8a5c33, var(--wood-light));
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.drawer-front:active {
  transform: translateY(2px);
}

.drawer-front[aria-pressed="true"] {
  background: linear-gradient(180deg, var(--brass-light), var(--brass));
  color: var(--wood-dark);
  border-color: var(--brass-dark);
  font-weight: 700;
}

.drawer-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.drawer-count {
  font-variant-numeric: tabular-nums;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 999px;
  padding: 0.05rem 0.5rem;
  font-size: 0.78rem;
}

.drawer-front[aria-pressed="true"] .drawer-count {
  background: rgba(0, 0, 0, 0.15);
}

/* -------------------- result summary -------------------- */

.result-summary {
  color: var(--paper);
  font-size: 0.85rem;
  margin: 0 0 0.9rem;
  opacity: 0.85;
}

/* -------------------- card index -------------------- */

.card-index {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(19rem, 1fr));
  gap: 1rem;
}

.card-index[hidden] {
  display: none;
}

.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), transparent 12%),
    var(--paper);
  border: 1px solid var(--paper-line);
  border-radius: var(--radius-card);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
  padding: 1.35rem 1rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.card-hole {
  position: absolute;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  width: 0.85rem;
  height: 0.85rem;
  border-radius: 50%;
  background: var(--wood);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6), 0 0 0 4px var(--wash-color, transparent);
}

.card-status-ribbon {
  align-self: flex-start;
  margin: 0;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #fff;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
}

.status-todo { background: var(--status-todo); }
.status-in-progress { background: var(--status-inprogress); }
.status-blocked { background: var(--status-blocked); }
.status-done { background: var(--status-done); }

.card-title {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.3;
  color: var(--ink);
  text-wrap: balance;
  overflow-wrap: break-word;
}

.card-meta {
  margin: 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.6rem;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.card-meta dt {
  font-weight: 700;
  grid-column: 1;
}

.card-meta dd {
  grid-column: 2;
  margin: 0;
  min-width: 0;
  overflow-wrap: break-word;
}

.card-tags {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  font-style: italic;
}

.card-summary {
  margin: 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  line-height: 1.4;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

.open-item-btn {
  margin-top: auto;
  align-self: flex-start;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--paper);
  background: linear-gradient(180deg, var(--wood-light), var(--wood-dark));
  border: 1px solid var(--wood-dark);
  border-radius: 3px;
  padding: 0.45rem 0.9rem;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.open-item-btn:hover {
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.open-item-btn:active {
  transform: translateY(1px);
}

/* -------------------- empty state -------------------- */

.empty-state {
  max-width: 28rem;
  margin: 3rem auto 0;
  text-align: center;
  background: var(--paper);
  border: 1px dashed var(--paper-line);
  border-radius: var(--radius-card);
  padding: 2rem 1.5rem;
}

.empty-state[hidden] {
  display: none;
}

.empty-state-title {
  margin: 0 0 0.4rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.empty-state-body {
  margin: 0 0 1rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

.empty-state button {
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--paper);
  background: var(--wood-dark);
  border: none;
  border-radius: 3px;
  padding: 0.55rem 1rem;
  cursor: pointer;
}

.empty-state button:hover {
  background: var(--wood);
}

/* -------------------- detail dialog -------------------- */

dialog#detail-dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(38rem, calc(100vw - 2rem));
  max-height: calc(100vh - 3rem);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--paper-line);
  border-radius: 6px;
  padding: 2.25rem 1.75rem 1.75rem;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

dialog#detail-dialog::backdrop {
  background: rgba(20, 12, 5, 0.65);
}

dialog#detail-dialog:not([open]) {
  display: none;
}

.detail-hole {
  position: absolute;
  top: 0.85rem;
  left: 50%;
  transform: translateX(-50%);
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  background: var(--wood);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.7);
}

.close-detail-btn {
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--paper);
  background: var(--wood-dark);
  border: none;
  border-radius: 999px;
  padding: 0.4rem 0.8rem 0.4rem 0.65rem;
  cursor: pointer;
  touch-action: manipulation;
}

.close-detail-btn span[aria-hidden] {
  font-size: 1.1rem;
  line-height: 1;
}

.close-detail-btn:hover {
  background: var(--wood);
}

.detail-ribbon {
  display: inline-block;
  margin: 0.5rem 0 0.75rem;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
  color: #fff;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
}

.detail-title {
  margin: 0 0 1rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.5rem;
  line-height: 1.3;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.detail-meta {
  margin: 0 0 1rem;
  display: grid;
  grid-template-columns: 9rem 1fr;
  gap: 0.5rem 0.75rem;
  font-size: 0.88rem;
}

.detail-meta-row {
  display: contents;
}

.detail-meta dt {
  font-weight: 700;
  color: var(--ink-soft);
}

.detail-meta dd {
  margin: 0;
  overflow-wrap: break-word;
}

.due-stamp {
  display: inline-block;
  border: 2px solid var(--priority-high);
  color: var(--priority-high);
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  transform: rotate(-2deg);
  margin-bottom: 1.25rem;
  font-family: Georgia, "Times New Roman", serif;
}

.due-stamp-label {
  margin: 0;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  text-align: center;
}

.due-stamp-date {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.detail-body {
  border-top: 1px dashed var(--paper-line);
  padding-top: 1rem;
  margin-bottom: 1.25rem;
}

.detail-body h3 {
  margin: 0 0 0.5rem;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
}

.detail-body p {
  margin: 0 0 0.75rem;
  line-height: 1.55;
  font-size: 0.92rem;
}

.detail-body p:last-child {
  margin-bottom: 0;
}

.status-stamp-block {
  border-top: 1px dashed var(--paper-line);
  padding-top: 1rem;
}

.status-stamp-block label {
  display: block;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.85rem;
  margin-bottom: 0.4rem;
  font-weight: 700;
}

.status-stamp-block select {
  font: inherit;
  font-size: 1rem;
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--paper-line);
  border-bottom: 2px solid var(--ink-soft);
  border-radius: 2px;
  background-color: #fffdf6;
  color: var(--ink);
  cursor: pointer;
  min-width: 12rem;
}

.status-feedback {
  margin: 0.6rem 0 0;
  min-height: 1.2em;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--status-done);
}

/* -------------------- visually hidden -------------------- */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* -------------------- responsive -------------------- */

@media (max-width: 640px) {
  .lookup-bar {
    grid-template-columns: 1fr;
  }

  .drawer-front {
    flex: 1 1 42%;
  }

  .card-index {
    grid-template-columns: 1fr;
  }

  dialog#detail-dialog {
    width: 100vw;
    max-width: 100vw;
    height: 100%;
    max-height: 100vh;
    border-radius: 0;
    inset: 0;
    padding: 2.5rem 1.25rem 2rem;
  }
}

/* -------------------- reduced motion -------------------- */

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