/* 
  The Daily Dread — Film-noir / detective case file web cartography.
  The CSS builds visual hierarchy around a dim map, bright pulp-print symbols,
  and newspaper clipping popups that remain legible on mobile.
*/

:root {
  --ink: #080808;
  --charcoal: #121212;
  --case: #211b17;
  --case-edge: #5b503f;
  --paper: #e7dcc3;
  --paper-dim: #c6b99d;
  --paper-dark: #6f654f;
  --white-ink: #f5f1e7;
  --muted: #b7b0a3;
  --accent: #f7d44a;
  --danger: #ff3b30;
  --shadow: rgba(0,0,0,.7);
  --panel-z: 900;
  --modal-z: 2000;
  --header-height: 132px;
  --ui-font: "Courier New", Courier, monospace;
  --headline-font: Impact, "Arial Black", "Franklin Gothic Heavy", Haettenschweiler, sans-serif;
  --serif-font: Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: #0b0b0b;
  color: var(--white-ink);
  font-family: var(--ui-font);
  overflow: hidden;
}

a { color: #ffe06d; }

#paper-grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .22;
  mix-blend-mode: screen;
  z-index: 1500;
  background-image:
    radial-gradient(rgba(255,255,255,.16) .55px, transparent .65px),
    radial-gradient(rgba(0,0,0,.28) .65px, transparent .75px),
    repeating-linear-gradient(0deg, rgba(255,255,255,.03), rgba(255,255,255,.03) 1px, transparent 1px, transparent 5px);
  background-size: 3px 3px, 5px 5px, 100% 5px;
}

.masthead {
  position: fixed;
  inset: 0 0 auto 0;
  height: var(--header-height);
  z-index: calc(var(--panel-z) + 20);
  display: grid;
  grid-template-columns: 140px 1fr 120px;
  align-items: center;
  padding: 12px 14px 16px;
  background:
    linear-gradient(180deg, rgba(0,0,0,.96), rgba(0,0,0,.82)),
    repeating-linear-gradient(90deg, rgba(255,255,255,.05) 0, rgba(255,255,255,.05) 1px, transparent 1px, transparent 14px);
  border-bottom: 4px double #d6c997;
  box-shadow: 0 12px 26px rgba(0,0,0,.6);
}

.masthead-inner {
  text-align: center;
  min-width: 0;
  align-self: center;
  padding: 2px 8px 8px;
}

.kicker, .dek {
  margin: 0;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--paper-dim);
  font-weight: 800;
}

.kicker {
  font-size: clamp(.62rem, 1.4vw, .86rem);
  margin-bottom: 5px;
}

.dek {
  font-size: clamp(.66rem, 1.6vw, .92rem);
  margin-top: 2px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

h1 {
  margin: 3px 0 7px;
  font-family: var(--headline-font);
  font-size: clamp(2rem, 6vw, 4.3rem);
  line-height: .88;
  letter-spacing: .035em;
  text-transform: uppercase;
  color: #f8f2df;
  text-shadow: 3px 3px 0 #000, 5px 5px 0 rgba(246, 32, 32, .42);
}

.case-tab, .sources-button,
.primary-action, .secondary-action,
.modal-close {
  border: 2px solid #d6c997;
  background: #0c0c0c;
  color: #f3e8ca;
  box-shadow: 4px 4px 0 rgba(0,0,0,.75);
  font-family: var(--ui-font);
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
}

.case-tab, .sources-button {
  padding: 10px 12px;
  border-radius: 0;
}

.sources-button { justify-self: end; }

#app {
  position: fixed;
  inset: var(--header-height) 0 0 0;
  display: block;
  z-index: 1;
}

.case-file {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 360px;
  z-index: var(--panel-z);
  min-width: 0;
  height: 100%;
  overflow: auto;
  padding: 18px 16px 28px;
  color: #1b160f;
  background:
    linear-gradient(90deg, rgba(0,0,0,.22), transparent 18px),
    radial-gradient(circle at 20% 10%, rgba(255,255,255,.24), transparent 25%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0, rgba(0,0,0,.035) 1px, transparent 1px, transparent 4px),
    #d6c59e;
  border-right: 6px solid #0b0b0b;
  box-shadow: 18px 0 28px rgba(0,0,0,.55);
  transition: transform .24s ease;
}

.case-file.closed { transform: translateX(-102%); }

.case-file::before {
  content: "";
  position: fixed;
  top: calc(var(--header-height) + 10px);
  left: 10px;
  bottom: 10px;
  width: 338px;
  border: 2px dashed rgba(54,38,17,.44);
  pointer-events: none;
}

.case-header {
  position: relative;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 4px double rgba(0,0,0,.7);
}

.stamp {
  float: right;
  transform: rotate(7deg);
  margin: 0 0 4px 8px;
  padding: 4px 8px;
  color: #831111;
  border: 3px solid #831111;
  font-family: var(--headline-font);
  font-size: 1.1rem;
  letter-spacing: .08em;
}

.case-header h2 {
  margin: 0;
  font-family: var(--headline-font);
  font-size: 2.2rem;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.result-count { margin: 3px 0 0; font-weight: 900; }

.field-block { margin: 14px 0; }

.field-block label, .legend-title {
  display: block;
  margin-bottom: 5px;
  font-family: var(--headline-font);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .07em;
}

input, select {
  width: 100%;
  padding: 11px 10px;
  border: 3px solid #20170d;
  background: #f0e5c9;
  color: #16110b;
  font-family: var(--ui-font);
  font-weight: 800;
  border-radius: 0;
  outline-offset: 3px;
}

details {
  margin: 11px 0;
  background: rgba(255,255,255,.15);
  border: 2px solid rgba(0,0,0,.62);
}

summary {
  padding: 10px;
  font-family: var(--headline-font);
  font-size: 1.08rem;
  text-transform: uppercase;
  cursor: pointer;
}

.check-grid, .tag-grid {
  display: grid;
  gap: 7px;
  padding: 0 10px 10px;
}

.check-grid { grid-template-columns: 1fr; }
.tag-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); max-height: 235px; overflow: auto; }

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 6px;
  border: 1px solid rgba(0,0,0,.28);
  background: rgba(255,255,255,.18);
  font-size: .86rem;
  font-weight: 900;
}

.check-item input { width: auto; accent-color: #1d1a16; }

.actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 9px;
  margin: 16px 0;
}

.primary-action, .secondary-action {
  padding: 11px 12px;
  color: #f9f1d5;
}

.primary-action { background: #2d100f; }
.secondary-action { background: #0d1d2c; }

.worrisome-things {
  color: #f3ead1;
  background: #12100e;
  border: 4px double #d6c997;
  box-shadow: inset 0 0 24px rgba(0,0,0,.7), 8px 8px 0 rgba(0,0,0,.45);
}

.map-legend-card {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: calc(var(--panel-z) - 10);
  width: min(270px, calc(100vw - 42px));
}

.legend-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 12px;
  border: 0;
  color: #f3ead1;
  background: rgba(0,0,0,.18);
  font-family: var(--headline-font);
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  cursor: pointer;
}

.legend-caret {
  font-family: var(--ui-font);
  font-size: 1.2rem;
  line-height: 1;
}

.legend-body {
  padding: 0 12px 12px;
  display: block;
}

.map-legend-card.collapsed .legend-body { display: none; }

.symbol-key {
  display: grid;
  gap: 6px;
}

.key-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .82rem;
  text-transform: capitalize;
}

.key-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid #111;
  box-shadow: 0 0 0 1px rgba(255,255,255,.5);
  flex: 0 0 auto;
}

.scale-note {
  margin-top: 10px;
  font-size: .76rem;
  color: #cfc4a7;
}

.map-wrap { position: absolute; inset: 0; min-width: 0; }

#map {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: #050505;
}

.leaflet-container {
  font-family: var(--ui-font);
  cursor: crosshair;
  background: #050505;
}

.leaflet-control-attribution {
  background: rgba(0,0,0,.72) !important;
  color: #c5bcaa !important;
  font-size: 10px;
  z-index: 300 !important;
}

.leaflet-control-attribution a { color: #f5d863 !important; }

.loading-state {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: calc(var(--panel-z) + 10);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: rgba(10,10,10,.92);
  border: 3px solid #d6c997;
  color: #f6edd4;
  box-shadow: 7px 7px 0 rgba(0,0,0,.55);
}

.loading-state.hidden { display: none; }

.spinner {
  width: 18px; height: 18px;
  border: 3px solid #555;
  border-top-color: #f6d64d;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.zoom-hint {
  position: absolute;
  right: 18px;
  bottom: 28px;
  z-index: 600;
  max-width: 280px;
  padding: 8px 10px;
  background: rgba(0,0,0,.72);
  border: 1px solid rgba(255,255,255,.35);
  color: #f1e6cb;
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  pointer-events: none;
}

.dread-marker,
.aggregate-marker {
  position: relative;
  border-radius: 50%;
  border: 2px solid rgba(4,4,4,.9);
  box-shadow:
    0 0 0 2px rgba(255,255,255,.62),
    0 0 14px rgba(255,255,255,.2),
    4px 4px 0 rgba(0,0,0,.5);
}

.dread-marker::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 50%;
  background: rgba(255,255,255,.32);
  transform: translate(-22%, -22%);
}

.aggregate-marker {
  display: grid;
  place-items: center;
  color: #111;
  font-family: var(--headline-font);
  font-weight: 900;
  text-shadow: 1px 1px 0 rgba(255,255,255,.72);
}

.aggregate-marker::before {
  content: "";
  position: absolute;
  inset: -7px;
  border-radius: 50%;
  border: 2px dashed rgba(255,255,255,.65);
  opacity: .72;
}

.aggregate-label {
  position: absolute;
  left: 50%;
  top: 100%;
  transform: translate(-50%, 7px);
  min-width: 110px;
  padding: 3px 6px;
  color: #f6efd8;
  background: rgba(0,0,0,.75);
  border: 1px solid rgba(255,255,255,.35);
  font-family: var(--ui-font);
  font-size: 10px;
  letter-spacing: .04em;
  text-transform: uppercase;
  text-align: center;
}

.leaflet-popup { margin-bottom: 8px; }

.leaflet-popup-content-wrapper {
  border-radius: 0;
  padding: 0;
  color: #1b160f;
  background:
    radial-gradient(circle at 30% 10%, rgba(255,255,255,.34), transparent 22%),
    repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0, rgba(0,0,0,.035) 1px, transparent 1px, transparent 4px),
    #eadfbf;
  border: 4px double #1c1710;
  box-shadow: 10px 12px 0 rgba(0,0,0,.5), 0 0 30px rgba(0,0,0,.75);
  transform: rotate(-.35deg);
}

.leaflet-popup-content {
  width: min(360px, 82vw) !important;
  margin: 0;
}

.leaflet-popup-tip {
  background: #eadfbf;
  border: 1px solid #1c1710;
}

.noir-popup {
  position: relative;
  padding: 14px 14px 13px;
}

.noir-popup .bulletin {
  display: inline-block;
  margin-bottom: 8px;
  padding: 3px 7px;
  background: #111;
  color: #f2e7c5;
  font-family: var(--headline-font);
  text-transform: uppercase;
  letter-spacing: .08em;
}

.noir-popup h3 {
  margin: 0 0 8px;
  font-family: var(--headline-font);
  font-size: 1.65rem;
  line-height: .92;
  text-transform: uppercase;
  letter-spacing: .02em;
}

.noir-popup .story {
  margin: 0 0 10px;
  font-family: var(--serif-font);
  font-size: .96rem;
  line-height: 1.32;
}

.noir-popup .story strong {
  font-family: var(--ui-font);
  font-size: .82rem;
  text-transform: uppercase;
  letter-spacing: .04em;
}

.noir-popup .meta-line {
  display: grid;
  grid-template-columns: 70px 1fr;
  gap: 8px;
  margin: 4px 0;
  font-size: .78rem;
  border-top: 1px solid rgba(0,0,0,.35);
  padding-top: 5px;
}

.noir-popup .meta-line b {
  font-family: var(--headline-font);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.save-box {
  margin: 10px 0;
  padding: 9px 10px;
  color: #f8edd0;
  background: #1b1b1b;
  border-left: 8px solid #c61e1e;
  box-shadow: inset 0 0 20px rgba(0,0,0,.65);
}

.save-box h4 {
  margin: 0 0 4px;
  font-family: var(--headline-font);
  letter-spacing: .07em;
  color: #ffdf43;
  text-transform: uppercase;
}

.save-box p {
  margin: 0 0 8px;
}

.save-box p:last-child { margin-bottom: 0; }

.save-box h4 + p + h4 {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,.18);
}

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.popup-tag {
  padding: 3px 6px;
  border: 1px solid #1b160f;
  background: rgba(0,0,0,.08);
  font-size: .68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.dread-index {
  position: absolute;
  right: -10px;
  top: -12px;
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  text-align: center;
  border-radius: 50%;
  background: #cf2424;
  color: #fff5d9;
  border: 3px solid #111;
  font-family: var(--headline-font);
  font-size: 1.15rem;
  line-height: .8;
  box-shadow: 4px 4px 0 rgba(0,0,0,.45);
}

.dread-index span {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.dread-index small {
  display: block;
  font-size: .45rem;
  line-height: 1;
  letter-spacing: .08em;
}

.aggregate-popup {
  width: min(340px, 80vw);
  padding: 12px;
  color: #1b160f;
}

.aggregate-popup h3 {
  margin: 0 0 4px;
  font-family: var(--headline-font);
  font-size: 1.9rem;
  text-transform: uppercase;
}

.aggregate-popup p { margin: 6px 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  z-index: var(--modal-z);
  padding: 20px;
  background: rgba(0,0,0,.72);
}

.modal-backdrop.open { display: grid; }

.modal-card {
  position: relative;
  width: min(820px, 96vw);
  max-height: min(720px, 90vh);
  overflow: auto;
  padding: 28px;
  color: #19140e;
  background:
    repeating-linear-gradient(0deg, rgba(0,0,0,.035) 0, rgba(0,0,0,.035) 1px, transparent 1px, transparent 4px),
    #e4d5b0;
  border: 6px double #111;
  box-shadow: 18px 18px 0 rgba(0,0,0,.55);
}

.modal-card h2 {
  margin: 0 36px 16px 0;
  text-align: center;
  font-family: var(--headline-font);
  font-size: clamp(1.7rem, 4vw, 2.8rem);
  line-height: .95;
  text-transform: uppercase;
}

.modal-close {
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 34px;
  font-size: 1.5rem;
  line-height: 1;
}

.modal-card a {
  color: #a51616;
  font-weight: 900;
  text-decoration-thickness: 2px;
  text-underline-offset: 2px;
}

.source-list {
  max-height: 260px;
  overflow: auto;
  padding-left: 18px;
  overflow-wrap: anywhere;
  font-size: .8rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(30px);
  opacity: 0;
  z-index: calc(var(--modal-z) + 10);
  max-width: min(560px, 92vw);
  padding: 12px 14px;
  color: #f8eed0;
  background: rgba(0,0,0,.88);
  border: 2px solid #d6c997;
  box-shadow: 6px 6px 0 rgba(0,0,0,.6);
  transition: opacity .22s ease, transform .22s ease;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

@media (max-width: 820px) {
  :root { --header-height: 122px; }
  .masthead {
    grid-template-columns: 52px 1fr 78px;
    padding: 7px;
  }
  .case-tab { width: 42px; height: 42px; padding: 0; overflow: hidden; }
  .sources-button { padding: 9px 7px; font-size: .72rem; }
  .dek { white-space: normal; }
  #app { display: block; }
  .case-file {
    position: fixed;
    left: 0;
    top: var(--header-height);
    bottom: 0;
    width: min(92vw, 370px);
    transform: translateX(-102%);
  }
  .case-file:not(.closed) { transform: translateX(0); }
  .map-wrap { position: absolute; inset: 0; height: 100%; }
  .map-legend-card { top: 12px; right: 12px; width: min(260px, calc(100vw - 24px)); }
  .zoom-hint { left: 12px; right: 12px; bottom: 18px; max-width: none; text-align: center; }
  .tag-grid { grid-template-columns: 1fr; }
}

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


.modal-card a { color: #9f1c16; font-weight: 900; text-decoration-thickness: 2px; }
.modal-card a:visited { color: #7f1512; }
