/* The Gift Office - Scranton drab, but make it Christmas. */
:root {
  --red: #c8202f;
  --red-dark: #9c1723;
  --green: #1f5e3b;
  --green-mid: #2f7d4f;
  --gold: #e3b341;
  --ink: #2b2b2b;
  --ink-soft: #5d5a52;
  --wall: #e8dfc8;
  --wall-dark: #d9cdb0;
  --carpet: #7d8a96;
  --manila: #f2dfa7;
  --manila-dark: #e3c97f;
  --paper: #fbf9f3;
  --sticky: #fff3a3;
  --line: #cfc5ad;
  --type: 'Courier Prime', 'Courier New', ui-monospace, monospace;
  --stamp: 'Special Elite', 'Courier Prime', monospace;
  --marker: 'Permanent Marker', 'Comic Sans MS', cursive;
  --sans: 'Work Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --shadow: 0 1px 0 rgba(0,0,0,.05), 0 6px 14px -6px rgba(0,0,0,.25);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--ink);
  background:
    linear-gradient(180deg, var(--wall) 0, var(--wall) var(--wall-h, 340px), transparent var(--wall-h, 340px)),
    /* cubicle partition fabric */
    repeating-linear-gradient(45deg, rgba(255,255,255,.05) 0 2px, transparent 2px 5px),
    repeating-linear-gradient(-45deg, rgba(0,0,0,.05) 0 2px, transparent 2px 5px),
    var(--carpet);
  min-height: 100vh;
}
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--green); }
img { max-width: 100%; }

/* ---------- drop ceiling + fluorescent lights ---------- */
.ceiling {
  height: 34px;
  background:
    linear-gradient(90deg, #cfcabd 2px, transparent 2px) 0 0 / 120px 100%,
    linear-gradient(180deg, #f1eee6, #e4e0d4);
  border-bottom: 3px solid #bdb7a8;
  display: flex; justify-content: space-around; align-items: center;
}
.fluoro {
  width: 110px; height: 18px; border: 2px solid #bdb7a8;
  background: repeating-linear-gradient(90deg, #fff 0 6px, #f4f7ff 6px 8px);
  box-shadow: 0 0 22px 6px rgba(255,255,240,.9);
}

/* ---------- Christmas lights ---------- */
.lights {
  height: 36px;
  margin-top: -6px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='36'%3E%3Cpath d='M0 6 Q30 22 60 6 T120 6' fill='none' stroke='%23284a34' stroke-width='2'/%3E%3Cg stroke='%23222' stroke-width='1'%3E%3Crect x='12' y='11' width='5' height='4' fill='%23555'/%3E%3Cellipse cx='14.5' cy='22' rx='5' ry='8' fill='%23e0323f'/%3E%3Crect x='42' y='11' width='5' height='4' fill='%23555'/%3E%3Cellipse cx='44.5' cy='22' rx='5' ry='8' fill='%23f2c14e'/%3E%3Crect x='72' y='11' width='5' height='4' fill='%23555'/%3E%3Cellipse cx='74.5' cy='22' rx='5' ry='8' fill='%232f9d5f'/%3E%3Crect x='102' y='11' width='5' height='4' fill='%23555'/%3E%3Cellipse cx='104.5' cy='22' rx='5' ry='8' fill='%233b7bd4'/%3E%3C/g%3E%3C/svg%3E") repeat-x;
  animation: twinkle 2.4s steps(2) infinite;
}
@keyframes twinkle { 50% { filter: brightness(1.25) saturate(1.3); } }
@media (prefers-reduced-motion: reduce) { .lights { animation: none; } }

/* ---------- masthead ---------- */
.masthead {
  max-width: 1200px; margin: 0 auto; padding: 8px 16px 0;
  display: flex; align-items: center; gap: 20px; flex-wrap: wrap;
}
.title-card {
  background: #fff; border: 2px solid var(--ink); padding: 14px 22px 10px;
  box-shadow: 4px 4px 0 var(--ink);
}
.logo {
  font-family: var(--type); font-size: clamp(30px, 6vw, 52px); line-height: 1; letter-spacing: -.02em;
  text-transform: lowercase;
}
.logo span { color: var(--red); }
.branch {
  font-family: var(--type); font-size: 13px; color: var(--ink-soft);
  margin-top: 6px; text-transform: uppercase; letter-spacing: .12em;
}
.hero-art { width: 150px; margin-left: auto; filter: drop-shadow(0 2px 0 rgba(0,0,0,.05)); }

.desk-calendar {
  width: 112px; text-align: center; background: #fff; border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink); font-family: var(--type);
}
.desk-calendar .cal-head {
  background: var(--red); color: #fff; font-size: 11px; font-weight: 700; padding: 4px 2px;
  letter-spacing: .08em; border-bottom: 2px solid var(--ink);
}
.desk-calendar .cal-num { font-size: 44px; font-weight: 700; line-height: 1.05; padding: 4px 0 0; }
.desk-calendar .cal-foot { font-size: 11px; color: var(--ink-soft); padding-bottom: 6px; }

/* ---------- documentary lower third ---------- */
.lower-third {
  max-width: 1200px; margin: 16px auto 0; padding: 0 16px;
  cursor: pointer; display: block; outline: none;
}
.lower-third .lt-inner {
  display: inline-block; background: linear-gradient(90deg, rgba(20,20,20,.88), rgba(20,20,20,.62));
  color: #fff; padding: 8px 18px 8px 14px; border-left: 6px solid var(--red);
}
.lower-third .lt-name { font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.lower-third .lt-title { font-size: 13px; opacity: .85; }
.lower-third:focus-visible .lt-inner { outline: 3px solid var(--gold); }

/* ---------- folder tabs ---------- */
.folder-tabs {
  max-width: 1200px; margin: 18px auto 0; padding: 0 16px;
  display: flex; gap: 6px; align-items: flex-end;
}
.tab {
  border: 2px solid var(--ink); border-bottom: none; border-radius: 10px 10px 0 0;
  background: var(--manila-dark); padding: 10px 16px 8px; font-family: var(--type); font-weight: 700;
  font-size: 15px; cursor: pointer; position: relative; top: 2px;
}
.tab[aria-selected="true"] { background: var(--paper); padding-top: 13px; z-index: 1; }
.tab-gear { margin-left: auto; font-size: 18px; padding: 8px 12px 6px; }
.badge {
  display: inline-block; min-width: 22px; padding: 1px 6px; margin-left: 4px; border-radius: 99px;
  background: var(--red); color: #fff; font-size: 12px; font-family: var(--sans);
}
.badge:empty { display: none; }

/* ---------- main paper ---------- */
.paper {
  max-width: 1200px; margin: 0 auto; background: var(--paper);
  border: 2px solid var(--ink); border-radius: 0 6px 6px 6px;
  padding: 20px 16px 28px; min-height: 360px; box-shadow: 0 10px 30px -10px rgba(0,0,0,.45);
}
@media (min-width: 1232px) { .paper { border-radius: 0 6px 6px 6px; } }
.loading { font-family: var(--type); text-align: center; padding: 60px 0; }

.view-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px 18px; margin: 0 0 16px;
}
.view-head h1 {
  font-family: var(--type); font-size: 26px; margin: 0;
  text-decoration: underline; text-decoration-color: var(--red); text-decoration-thickness: 3px; text-underline-offset: 5px;
}
.memo { font-family: var(--type); color: var(--ink-soft); font-size: 14px; }

.stats { display: flex; flex-wrap: wrap; gap: 8px; margin-left: auto; }
.stat {
  font-family: var(--type); font-size: 13px; background: #fff; border: 1.5px solid var(--ink);
  padding: 4px 10px; border-radius: 3px;
}
.stat b { color: var(--red); }

/* ---------- people grid ---------- */
.people {
  display: grid; gap: 22px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 330px), 1fr));
  align-items: start;
}
.folder {
  position: relative; margin-top: 18px;
  background: var(--manila); border: 2px solid var(--ink); border-radius: 0 8px 8px 8px;
  box-shadow: var(--shadow);
}
.folder::before {
  /* the folder's tab */
  content: ''; position: absolute; top: -18px; left: -2px; width: 46%; height: 18px;
  background: var(--manila); border: 2px solid var(--ink); border-bottom: none; border-radius: 8px 8px 0 0;
}
.folder-head {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 0 12px;
  margin-top: -16px;
}
.folder-name {
  font-family: var(--marker); font-size: 24px; line-height: 1.1; margin: 0; padding: 0 2px;
  color: var(--green); background: none; border: none; cursor: pointer; text-align: left;
}
.folder-name:hover { color: var(--red); }
.folder-actions { margin-left: auto; display: flex; gap: 4px; align-items: center; padding-top: 18px; }

.stamp {
  font-family: var(--stamp); font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  border: 2px solid currentColor; padding: 1px 6px; transform: rotate(-6deg); background: none;
  cursor: pointer; color: var(--ink-soft); opacity: .55;
}
.stamp.admirable { color: var(--green-mid); opacity: 1; }
.stamp.impish { color: var(--red); opacity: 1; }

.folder-body { padding: 10px 12px 12px; }
.sticky {
  background: var(--sticky); padding: 8px 10px; font-size: 14px; margin: 4px 0 10px;
  box-shadow: 0 2px 4px rgba(0,0,0,.15); transform: rotate(-.6deg); cursor: pointer; white-space: pre-wrap;
}
.sticky.empty { color: var(--ink-soft); font-style: italic; }

.budget { font-family: var(--type); font-size: 12px; margin: 0 0 10px; }
.budget-bar { height: 8px; background: #fff; border: 1.5px solid var(--ink); border-radius: 99px; overflow: hidden; margin-top: 3px; }
.budget-bar span { display: block; height: 100%; background: var(--green-mid); }
.budget-bar.over span { background: var(--red); }

.gift-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.gift {
  background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; padding: 8px 10px;
  display: grid; grid-template-columns: auto 1fr; gap: 4px 10px; align-items: start;
}
.gift.is-bought { background: #eef6f0; }
.gift-main { min-width: 0; }
.gift-title { font-weight: 600; word-break: break-word; }
.gift-meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; margin-top: 3px; font-size: 13px; color: var(--ink-soft); }
.price { font-family: var(--type); font-weight: 700; color: var(--green); }
.thumb { width: 44px; height: 44px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 3px; float: right; margin: 0 0 4px 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 3px; font-size: 12px; padding: 1px 7px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink); text-decoration: none; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip:hover { border-color: var(--green); color: var(--green); }
.who { font-family: var(--type); font-size: 12px; }

.gift-tools { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; }
.tool {
  border: 1.5px solid var(--ink); background: var(--paper); border-radius: 4px; padding: 3px 8px;
  font-size: 13px; cursor: pointer; line-height: 1.3;
}
.tool:hover { background: var(--sticky); }
.tool.danger:hover { background: #fde2e4; }
.tool.ai { border-color: var(--green); color: var(--green); font-weight: 600; }

.research {
  grid-column: 1 / -1; background: var(--paper); border: 1px dashed var(--ink-soft); border-radius: 4px;
  padding: 8px 10px; font-size: 14px;
}
.research h4 { font-family: var(--type); font-size: 13px; margin: 10px 0 4px; color: var(--red); text-transform: uppercase; letter-spacing: .05em; }
.research ul { margin: 0; padding-left: 18px; }
.research li { margin: 3px 0; }
.research p { margin: 0 0 6px; }
.research .save-link { border: none; background: none; color: var(--green); cursor: pointer; font-size: 12px; padding: 0 2px; text-decoration: underline; }
.research small { color: var(--ink-soft); font-family: var(--type); }

.search-menu {
  grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 4px; padding: 6px; background: var(--paper);
  border: 1px dashed var(--ink-soft); border-radius: 4px;
}
.search-menu a { font-size: 13px; }

.gift-notes { grid-column: 1 / -1; font-size: 13px; white-space: pre-wrap; color: var(--ink-soft); }

/* checkboxes - big, festive, thumb-friendly */
.check { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; font-family: var(--type); font-size: 13px; font-weight: 700; user-select: none; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box {
  width: 26px; height: 26px; border: 2.5px solid var(--ink); border-radius: 4px; background: #fff;
  display: grid; place-items: center; flex: none; transition: background .15s;
}
.check input:checked + .box { background: var(--red); }
.check input:checked + .box::after {
  content: ''; width: 7px; height: 13px; border: solid #fff; border-width: 0 3.5px 3.5px 0; transform: translateY(-2px) rotate(45deg);
}
.check.green input:checked + .box { background: var(--green-mid); }
.check input:focus-visible + .box { outline: 3px solid var(--gold); outline-offset: 2px; }

.add-gift { display: flex; gap: 6px; margin-top: 10px; }
.add-gift input {
  flex: 1; min-width: 0; border: 1.5px solid var(--ink); border-radius: 4px; padding: 8px 10px; background: #fff;
}
.btn {
  border: 2px solid var(--ink); border-radius: 4px; background: var(--red); color: #fff; font-weight: 700;
  padding: 8px 14px; cursor: pointer; box-shadow: 2px 2px 0 var(--ink); white-space: nowrap;
}
.btn:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.btn.green { background: var(--green-mid); }
.btn.plain { background: #fff; color: var(--ink); }
.btn[disabled] { opacity: .6; cursor: progress; }
.card-foot { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }

.empty-list { font-family: var(--type); font-size: 13px; color: var(--ink-soft); padding: 4px 2px; }

.add-person {
  margin-top: 18px; min-height: 180px; border: 2.5px dashed var(--ink-soft); border-radius: 8px;
  background: rgba(255,243,163,.4); cursor: pointer; display: grid; place-items: center;
  font-family: var(--marker); font-size: 22px; color: var(--ink-soft);
}
.add-person:hover { background: var(--sticky); color: var(--ink); border-color: var(--ink); }

.suggestions { grid-column: 1 / -1; display: grid; gap: 6px; margin-top: 8px; }
.suggestion { display: flex; gap: 8px; align-items: flex-start; background: var(--sticky); padding: 6px 8px; border-radius: 3px; font-size: 13px; }
.suggestion div { flex: 1; }
.suggestion b { display: block; font-size: 14px; }

/* ---------- bought cards ---------- */
.bought-item { background: #fff; border: 1.5px solid var(--ink); border-radius: 4px; padding: 8px 10px; }
.bought-item.stage-1 { border-left: 6px solid var(--red); }
.bought-item.stage-2 { background: #eef6f0; border-left: 6px solid var(--green-mid); }
.bought-item .row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-top: 8px; }
.bought-item .row-tools { margin-left: auto; display: flex; gap: 4px; }
.stage-tag { font-family: var(--type); font-size: 12px; font-weight: 700; color: var(--ink); }
.stage-1 .stage-tag { color: var(--red); }
.stage-2 .stage-tag { color: var(--green); }
.folder.all-wrapped { background: #dcebdf; }
.folder.all-wrapped::before { background: #dcebdf; }

.empty-art { text-align: center; padding: 18px 8px; font-family: var(--type); color: var(--ink-soft); font-size: 14px; }
.empty-art img { width: 110px; display: block; margin: 0 auto 6px; opacity: .9; }

/* ---------- footer ---------- */
.footer { max-width: 1200px; margin: 0 auto; padding: 22px 16px 40px; text-align: center; }
.desk-row { display: flex; justify-content: center; align-items: flex-end; gap: clamp(10px, 4vw, 40px); }
.desk-row img { height: clamp(60px, 12vw, 110px); }
.quote { font-family: var(--type); color: #f4f1e8; font-size: 15px; margin: 14px auto 0; max-width: 640px; text-shadow: 0 1px 0 rgba(0,0,0,.4); }

/* ---------- modal ---------- */
dialog {
  border: 2px solid var(--ink); border-radius: 6px; padding: 0; width: min(520px, calc(100vw - 24px));
  background: var(--paper); box-shadow: 6px 6px 0 var(--ink); color: var(--ink);
}
dialog::backdrop { background: rgba(30, 40, 35, .55); }
.modal-head { background: var(--green); color: #fff; padding: 12px 16px; font-family: var(--type); font-weight: 700; font-size: 18px; border-bottom: 2px solid var(--ink); }
.modal-body { padding: 14px 16px; display: grid; gap: 12px; max-height: 70vh; overflow: auto; }
.modal-foot { padding: 12px 16px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; border-top: 1.5px solid var(--line); }
.modal-foot .left { margin-right: auto; }
.field { display: grid; gap: 4px; }
.field > span { font-family: var(--type); font-size: 13px; font-weight: 700; }
.field input, .field textarea, .field select {
  border: 1.5px solid var(--ink); border-radius: 4px; padding: 8px 10px; background: #fff; width: 100%;
}
.field textarea { min-height: 70px; resize: vertical; }
.field small { color: var(--ink-soft); font-size: 12px; }
.links-edit { display: grid; gap: 6px; }
.link-row { display: flex; gap: 6px; align-items: center; }
.link-row input { flex: 1; min-width: 0; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 20px; transform: translate(-50%, 140%); transition: transform .25s;
  background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 4px; border-left: 6px solid var(--gold);
  font-size: 14px; display: flex; gap: 12px; align-items: center; z-index: 50; max-width: calc(100vw - 24px);
}
.toast.show { transform: translate(-50%, 0); }
.toast button { background: none; border: 1.5px solid #fff; color: #fff; border-radius: 3px; padding: 2px 8px; cursor: pointer; }

/* ---------- login ---------- */
.login { max-width: 360px; margin: 30px auto; text-align: center; display: grid; gap: 12px; }
.login input { border: 2px solid var(--ink); border-radius: 4px; padding: 10px; text-align: center; font-size: 18px; }
.login .error { color: var(--red); font-family: var(--type); }

.spin { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 560px) {
  body { --wall-h: 270px; }
  .hero-art { display: none; }
  .masthead { gap: 10px; flex-wrap: nowrap; }
  .title-card { flex: 1; min-width: 0; padding: 10px 12px 8px; box-shadow: 3px 3px 0 var(--ink); }
  .logo { font-size: clamp(24px, 8.4vw, 34px); }
  .branch { font-size: 10px; letter-spacing: .06em; }
  .desk-calendar { width: 78px; flex: none; }
  .desk-calendar .cal-head { font-size: 9px; }
  .desk-calendar .cal-num { font-size: 30px; }
  .desk-calendar .cal-foot { font-size: 9px; }
  .lower-third .lt-name { font-size: 16px; }
  .tab { padding: 9px 10px 7px; font-size: 14px; }
  .tab .long { display: none; }
  .paper { padding: 16px 10px 22px; }
  .row2 { grid-template-columns: 1fr; }
}
