:root {
  --ink: #000;
  --orange: #ff5a00;
  --paper: #fff;
  --line: rgba(0,0,0,.09);
  --dim: rgba(0,0,0,.45);
  --hole: clamp(18px, 2.4vw, 34px);
  --gutter: clamp(44px, 6vw, 90px);
  --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--ink); overflow: hidden; }
body { font-family: var(--mono); color: var(--ink); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }

#paper {
  position: fixed; inset: 10px;
  background: var(--paper);
  overflow: hidden;
  cursor: crosshair;
}

/* punched holes: show the black table beneath */
.holes { position: absolute; top: 0; bottom: 0; width: var(--gutter);
  display: flex; flex-direction: column; justify-content: space-between;
  align-items: center; padding: 7vh 0; z-index: 6; pointer-events: none; }
.holes.left { left: 0; } .holes.right { right: 0; }
.holes i { width: var(--hole); height: var(--hole); border-radius: 50%; background: var(--ink);
  box-shadow: inset 0 1px 2px rgba(255,255,255,.08); }

#grid, #trails { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#grid line { stroke: var(--line); stroke-width: 1; }
#grid .axis { stroke: rgba(0,0,0,.22); }
#grid text { font: 8px var(--mono); fill: var(--dim); letter-spacing: .06em; }

/* margin notes */
.meta { position: absolute; z-index: 7; font-size: 10px; letter-spacing: .08em; line-height: 1.7; text-transform: uppercase; }
.meta.tl { top: 18px; left: calc(var(--gutter) + 8px); }
.meta.tr { top: 18px; right: calc(var(--gutter) + 8px); display: flex; gap: 14px; }
.meta.bl { bottom: 16px; left: calc(var(--gutter) + 8px); }
.meta.br { bottom: 16px; right: calc(var(--gutter) + 8px); font-variant-numeric: tabular-nums; }
.meta.bc { bottom: 16px; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.dim { color: var(--dim); }
.filter { padding: 2px 6px; letter-spacing: .08em; }
.filter span { color: var(--dim); }
.filter.on { background: var(--ink); color: var(--paper); }
.filter.on span { color: rgba(255,255,255,.6); }
.filter:focus-visible, #card button:focus-visible { outline: 1px solid var(--ink); outline-offset: 2px; }
.legend { display: flex; align-items: center; gap: 8px; }
.sw { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.sw.solid { background: var(--ink); }
.sw.ring { border: 1px solid var(--ink); }

/* the hill */
#hill { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 2; pointer-events: none; }
#title { font-size: 11px; font-weight: 500; letter-spacing: .32em; white-space: nowrap; }

/* ants */
#colony { position: absolute; inset: 0; z-index: 4; }
.ant { position: absolute; left: 0; top: 0; width: 46px; height: 30px; margin: -15px 0 0 -23px;
  will-change: transform; cursor: pointer; }
.ant .rot { width: 100%; height: 100%; }
.ant .body { width: 100%; height: 100%; background: var(--ink); transition: background-color .15s;
  -webkit-mask: url(assets/ant.png) center/contain no-repeat; mask: url(assets/ant.png) center/contain no-repeat;
  animation: scuttle .15s steps(2) infinite; }
.ant:hover .body, .ant.held .body, .ant:focus-visible .body { background: var(--orange); }
.ant.kitchen .body { filter: none; }
.ant .tag { position: absolute; left: 50%; top: 50%; pointer-events: none;
  font-size: 8px; letter-spacing: .06em; background: var(--ink); color: var(--paper);
  padding: 1px 4px; transform: translate(14px, -26px); white-space: nowrap; opacity: 0; transition: opacity .15s; }
.ant.kitchen .tag { background: var(--paper); color: var(--ink); border: 1px solid var(--ink); }
.ant .ring { position: absolute; left: 50%; top: 50%; width: 64px; height: 64px; margin: -32px;
  border: 1px solid var(--ink); border-radius: 50%; opacity: 0; transform: scale(.6);
  transition: opacity .15s, transform .25s; pointer-events: none; }
.ant .ring::before, .ant .ring::after { content: ""; position: absolute; background: var(--ink); }
.ant .ring::before { left: 50%; top: -6px; bottom: -6px; width: 1px; }
.ant .ring::after { top: 50%; left: -6px; right: -6px; height: 1px; }
.ant:hover .ring, .ant.held .ring, .ant:focus-visible .ring { opacity: 1; transform: scale(1); }
.ant:hover .tag, .ant.held .tag, .ant:focus-visible .tag { opacity: 1; }
.ant:hover .body, .ant.held .body { animation-play-state: paused; }
.ant.dim { opacity: .12; pointer-events: none; }
.ant:focus { outline: none; }
@keyframes scuttle { from { transform: translateY(-.6px) rotate(-2deg); } to { transform: translateY(.6px) rotate(2deg); } }

/* card */
#card { position: absolute; z-index: 9; width: min(340px, calc(100% - 2 * var(--gutter)));
  background: var(--paper); border: 1px solid var(--ink); padding: 12px;
  box-shadow: 6px 6px 0 var(--ink); font-size: 10px; letter-spacing: .04em;
  animation: pop .22s cubic-bezier(.2,1.4,.4,1); cursor: default; }
#card[hidden] { display: none; }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }
.card-head { display: flex; gap: 10px; align-items: center; border-bottom: 1px solid var(--ink); padding-bottom: 8px; }
#card-no { background: var(--ink); color: var(--paper); padding: 1px 5px; }
#card-cat { color: var(--dim); }
#card-close { margin-left: auto; letter-spacing: .08em; }
.card-img { margin: 12px 0; aspect-ratio: 4/3; border: 1px solid var(--ink); display: grid; place-items: center;
  background: repeating-linear-gradient(45deg, transparent 0 7px, rgba(0,0,0,.08) 7px 8px);
  background-size: cover; background-position: center; }
.card-img span { background: var(--paper); padding: 2px 6px; color: var(--dim); }
.card-img.has-img span { display: none; }
#card h2 { font-size: 22px; font-weight: 500; letter-spacing: -.01em; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; margin-bottom: 10px; }
.card-meta { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding: 6px 0; margin-bottom: 10px; }
.card-meta dt { color: var(--dim); font-size: 8px; }
.card-meta dd { font-size: 10px; }
#card p { line-height: 1.55; font-size: 11px; }
.card-foot { margin-top: 12px; display: flex; justify-content: flex-end; }
#card-release { border: 1px solid var(--ink); padding: 4px 8px; letter-spacing: .08em; }
#card-release:hover, #card-close:hover { background: var(--ink); color: var(--paper); }

@media (max-width: 700px) {
  .meta.tr { top: 58px; left: calc(var(--gutter) + 8px); right: auto; gap: 6px; }
  .meta.bc.hint, .meta.br { display: none; }
  .view { bottom: 18px !important; }
  .ant { width: 36px; height: 24px; margin: -12px 0 0 -18px; }
  #card { left: 50% !important; top: 50% !important; transform: translate(-50%, -50%); animation: none; }
}
@media (prefers-reduced-motion: reduce) {
  .ant .body { animation: none; }
}

/* quadrant segment labels */
#segments { position: absolute; inset: 0; pointer-events: none; z-index: 3; }
.seg { position: absolute; left: 0; top: 0; font-size: 10px; letter-spacing: .1em; white-space: nowrap;
  display: flex; align-items: center; gap: 8px; transition: opacity .2s; }
.seg b { font-weight: 500; background: var(--ink); color: var(--paper); padding: 1px 5px; }
.seg span { color: var(--dim); }
.seg.on b { background: var(--orange); }
.meta.tr { flex-wrap: wrap; justify-content: flex-end; max-width: 60%; }
@media (max-width: 700px) { .seg { font-size: 8px; gap: 4px; } .meta.tr { max-width: none; justify-content: flex-start; } }
.seg.right { flex-direction: row-reverse; }

/* ---------- view switch (iOS-style) ---------- */
.view { bottom: 36px !important; display: flex; gap: 10px; align-items: center; }
.view .lbl { letter-spacing: .1em; color: var(--dim); padding: 2px 0; transition: color .2s; }
.view .lbl.on { color: var(--ink); }
.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: #d9d9d9;
  transition: background-color .25s; flex: none; }
.switch i { position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,.3), 0 0 0 .5px rgba(0,0,0,.06); transition: transform .25s cubic-bezier(.3,1.3,.5,1); }
.switch[aria-checked="true"] { background: var(--ink); }
.switch[aria-checked="true"] i { transform: translateX(18px); }
.switch:focus-visible, .view .lbl:focus-visible { outline: 1px solid currentColor; outline-offset: 3px; }

/* ---------- nature view ---------- */
#nature { position: absolute; inset: 0; z-index: 1; display: none; overflow: hidden;
  background: #a9c6d3; pointer-events: none; }
#stage { position: absolute; will-change: transform; contain: strict; left: 0; top: 0; width: 1600px; height: 1000px; transform-origin: 0 0; }
#stage svg { display: block; }
.nature #nature { display: block; }
@keyframes fadein { from { opacity: 0; } }
.nature #grid, .nature #trails, .nature #segments { display: none; }
.nature #hill { top: 12%; }
.nature #title { color: #1d2a22; }

.nseg { position: absolute; font-size: 11px; letter-spacing: .1em; white-space: nowrap;
  display: flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px;
  background: rgba(250, 244, 226, .88); color: #1b140c; }
.nseg.center { transform: translate(-50%, -100%); }
.nseg.left { transform: translate(0, -100%); }
.nseg.right { transform: translate(-100%, -100%); flex-direction: row-reverse; padding: 3px 3px 3px 8px; }
.nseg b { font-weight: 500; background: #1b140c; color: #faf4e2; padding: 1px 5px; }
.nseg span { color: rgba(27, 20, 12, .5); }
.nseg.on b { background: var(--orange); }

/* nature ants: solid black, orange only on hover / select */
.nature .ant .body { background: #000; }
.nature .ant:hover .body, .nature .ant.held .body, .nature .ant:focus-visible .body { background: var(--orange); }
.nature .ant .ring { border-color: #faf4e2; }
.nature .ant .ring::before, .nature .ant .ring::after { background: #faf4e2; }

/* margin notes that sit on soil */
.nature .meta.bl, .nature .meta.br, .nature .meta.bc { color: #f3ead0; }
.nature .meta.bl .dim, .nature .meta.br.dim, .nature .meta.bc.dim { color: rgba(243, 234, 208, .7); }
.nature .view .lbl { color: rgba(243, 234, 208, .6); }
.nature .view .lbl.on { color: #f3ead0; }
.nature .switch[aria-checked="true"] { background: #f3ead0; }
.nature .switch[aria-checked="true"] i { background: #1b140c; }
.nature .meta.tl .dim { color: rgba(20, 30, 25, .6); }
@media (max-width: 700px) {
  .nature #hill { top: 30%; }
  .nseg { font-size: 15px; }
}
