/* Adaptlab — canal lock staircase / lock-keeper's cabin. */
/* data-redesign="canal-lock-staircase-20260824" */

:root {
  --paper: #f3ead8;
  --cabin: #e7dcc6;
  --log: #fbf6ea;
  --ink: #1a1714;
  --mute: #5c564c;
  --water: #1e6d6c;
  --water-lit: #2a8f8c;
  --foam: #d5efe8;
  --gate: #7c2f2c;
  --gate-hot: #9a3c38;
  --brass: #c4a054;
  --brass-hot: #d8b66a;
  --oak: #6a4530;
  --iron: #2a2724;
  --good: #2a9a68;
  --warn: #d4a017;
  --rule: #d4cbb8;
  --max: 1100px;
  --display: Palatino, "Palatino Linotype", "Iowan Old Style", "Times New Roman", serif;
  --sans: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --mono: "SFMono-Regular", ui-monospace, Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --radius: 12px;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
::selection { background: rgba(30, 109, 108, 0.22); color: var(--ink); }

body {
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  font-size: 1.02rem;
  line-height: 1.55;
  background-color: var(--paper);
  background-image:
    linear-gradient(180deg, rgba(106, 69, 48, 0.05), transparent 180px),
    repeating-linear-gradient(
      90deg,
      transparent 0 47px,
      rgba(106, 69, 48, 0.045) 47px 48px
    );
}

body::before {
  content: "";
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.055;
  background:
    radial-gradient(ellipse 1.2px 0.8px at 30% 40%, rgba(26, 23, 20, 0.55) 70%, transparent 72%),
    repeating-linear-gradient(180deg, transparent 0 3px, rgba(30, 109, 108, 0.03) 3px 4px);
  background-size: 18px 14px, auto;
}

h1, h2, h3 {
  font-family: var(--display);
  letter-spacing: -0.02em;
  line-height: 1.12;
}
h1 { margin: 0 0 1rem; font-size: clamp(2.25rem, 4.6vw, 3.2rem); font-weight: 600; }
h2 { font-size: clamp(1.45rem, 2.6vw, 2rem); margin: 0 0 0.65rem; }
h3 { font-size: 1.12rem; margin: 0 0 0.4rem; }
p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }
button, input, select, textarea { font-family: inherit; }

a { color: var(--water); }
a:hover { color: var(--gate); }
a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible,
.chip:focus-visible,
.chamber-tab:focus-visible {
  outline: 2px solid var(--brass);
  outline-offset: 3px;
}

.wrap { width: min(var(--max), calc(100% - 4.5rem)); margin: 0 auto; position: relative; z-index: 1; }
.skip { position: absolute; left: -999px; top: 0; }
.skip:focus { left: 1rem; top: 1rem; z-index: 80; background: var(--log); padding: 0.4rem 0.7rem; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: 0.72rem 0;
  background: linear-gradient(180deg, #efe6d2 0%, var(--cabin) 100%);
  border-bottom: 3px solid var(--gate);
  box-shadow: 0 10px 24px rgba(26, 23, 20, 0.08);
}
.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  text-decoration: none;
  color: var(--ink);
  font-family: var(--display);
  font-size: 1.28rem;
  font-weight: 600;
}
.wordmark svg { width: 28px; height: 28px; flex: 0 0 28px; }
.wordmark:hover { color: var(--gate); }
.wordmark .wheel { transform-origin: 19px 14px; animation: spin 16s linear infinite; }
.lock-scene .wheel,
.illust .wheel {
  transform-box: fill-box;
  transform-origin: center;
  animation: spin 16s linear infinite;
}
.nav-toggle {
  display: none;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--oak);
  border-radius: 8px;
  padding: 0.4rem 0.7rem;
  cursor: pointer;
}
.nav-list {
  display: flex;
  align-items: center;
  gap: 1.15rem;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.92rem;
}
.nav-list a { color: var(--ink); text-decoration: none; }
.nav-list a:hover { color: var(--water); }
.nav-list a[aria-current="page"] { color: var(--gate); font-weight: 600; }

.btn {
  display: inline-block;
  background: var(--gate);
  color: #fbf6ea !important;
  text-decoration: none;
  padding: 0.55rem 1.05rem;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.22s var(--ease), transform 0.22s var(--ease);
}
.btn:hover { background: var(--gate-hot); transform: translateY(-1px); }
.btn-ghost {
  background: transparent;
  color: var(--ink) !important;
  border: 1.5px solid var(--ink);
}
.btn-ghost:hover { background: rgba(26, 23, 20, 0.05); }
.hero-actions { display: flex; flex-wrap: wrap; gap: 0.7rem; margin-top: 1.25rem; }

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0 0 0.7rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--water);
}
.sluice-dot {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--brass);
  box-shadow: 0 0 8px var(--brass);
  animation: glow 2.8s ease-in-out infinite;
}
.lede { font-size: 1.12rem; color: var(--mute); max-width: 38rem; }
.note { font-size: 0.88rem; color: var(--mute); }

.hero-band {
  position: relative;
  padding: 3.4rem 0 1.2rem;
  background:
    linear-gradient(180deg, rgba(30, 109, 108, 0.12) 0%, transparent 42%),
    radial-gradient(ellipse 70% 50% at 88% 8%, rgba(196, 160, 84, 0.18), transparent 55%);
  overflow: hidden;
}
.hero-band::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 28px;
  background: repeating-linear-gradient(
    90deg,
    var(--water) 0 18px,
    var(--water-lit) 18px 22px,
    var(--water) 22px 40px
  );
  opacity: 0.22;
  animation: current 8s linear infinite;
}
.hero {
  display: grid;
  grid-template-columns: 0.92fr 1.08fr;
  gap: 2.2rem;
  align-items: start;
  padding-bottom: 2rem;
}

.lock-frame {
  position: relative;
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px rgba(26, 23, 20, 0.1);
  overflow: hidden;
}
.lock-frame .fly {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.55rem 0.85rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  background: var(--cabin);
  border-bottom: 1px solid var(--rule);
}
.lock-scene { display: block; width: 100%; height: auto; }
.boat { animation: drift 7s ease-in-out infinite; }
.water-shim { animation: bob 5.5s ease-in-out infinite; }
.gate-arm { transform-origin: 8px 8px; }

.chips {
  position: absolute;
  inset: 2.6rem 0.7rem 0.7rem;
  pointer-events: none;
}
.chip {
  pointer-events: auto;
  position: absolute;
  background: rgba(251, 246, 234, 0.94);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.42rem 0.62rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.25;
  box-shadow: 0 8px 18px rgba(26, 23, 20, 0.08);
  animation: bob 4.8s ease-in-out infinite;
}
.chip strong { display: block; color: var(--good); font-weight: 700; }
.chip .watch { color: var(--warn); }
.chip:nth-child(1) { left: 4%; top: 6%; }
.chip:nth-child(2) { right: 5%; top: 18%; animation-delay: 0.6s; }
.chip:nth-child(3) { left: 10%; bottom: 22%; animation-delay: 1.1s; }
.chip:nth-child(4) { right: 8%; bottom: 8%; animation-delay: 1.7s; }
.chip:hover { border-color: var(--brass); transform: translateY(-2px); }

.gauges {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.85rem;
  padding: 1.4rem 0 0.4rem;
}
.gauge {
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.05rem 0.95rem;
  box-shadow: 0 10px 24px rgba(26, 23, 20, 0.06);
}
.gauge .label {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}
.gauge .val {
  font-family: var(--mono);
  font-size: 1.35rem;
  color: var(--good);
  margin: 0.35rem 0 0.5rem;
}
.level {
  height: 8px;
  background: rgba(30, 109, 108, 0.15);
  border-radius: 99px;
  overflow: hidden;
}
.level span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--water), var(--water-lit));
  border-radius: inherit;
  transform-origin: left;
  animation: fill 1.6s var(--ease) both;
}
.disclaimer {
  grid-column: 1 / -1;
  font-family: var(--mono);
  font-size: 0.75rem;
  color: var(--mute);
  margin: 0;
}

.section { padding: 3.4rem 0; }
.section.watery {
  background:
    linear-gradient(180deg, rgba(30, 109, 108, 0.08), rgba(243, 234, 216, 0.2) 40%, var(--paper));
}

.chapter-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin: 1.1rem 0 1.4rem;
}
.chamber-tab {
  background: transparent;
  border: 1.5px solid var(--oak);
  color: var(--ink);
  border-radius: 999px;
  padding: 0.4rem 0.9rem;
  cursor: pointer;
  font-size: 0.88rem;
}
.chamber-tab:hover { border-color: var(--water); }
.chamber-tab.is-on {
  background: var(--water);
  border-color: var(--water);
  color: #fbf6ea;
}

.chambers { display: grid; gap: 1rem; }
.chamber {
  display: none;
  grid-template-columns: 0.42fr 0.58fr;
  gap: 1.2rem;
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: 0 14px 32px rgba(26, 23, 20, 0.07);
}
.chamber.is-on { display: grid; }
.chamber .num {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gate);
  margin: 0 0 0.4rem;
}
.logbook {
  background: var(--iron);
  color: #efe8d8;
  border-radius: 10px;
  padding: 0.9rem;
  font-family: var(--mono);
  font-size: 0.78rem;
}
.logbook .bar {
  display: flex;
  justify-content: space-between;
  color: var(--brass);
  margin-bottom: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.log-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.5rem;
  padding: 0.38rem 0;
  border-bottom: 1px solid rgba(239, 232, 216, 0.08);
}
.log-row .tag {
  color: var(--brass-hot);
  font-size: 0.68rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.log-row .up { color: #6ee0a8; }
.cand {
  display: grid;
  grid-template-columns: 1.4fr 0.6fr 0.6fr 0.5fr;
  gap: 0.4rem;
  padding: 0.32rem 0;
  border-bottom: 1px solid rgba(239, 232, 216, 0.08);
}
.cand.head { color: var(--brass); text-transform: uppercase; font-size: 0.65rem; letter-spacing: 0.08em; }
.cand.win { color: #6ee0a8; }

.loop {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1.4rem;
}
.loop article {
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.15rem 1.2rem 1.2rem;
  position: relative;
}
.loop article::before {
  content: "";
  position: absolute;
  left: 1.2rem;
  right: 1.2rem;
  top: 0;
  height: 4px;
  background: var(--water);
  border-radius: 0 0 4px 4px;
}
.loop .step {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--water);
  margin: 0.4rem 0 0.35rem;
}

.staircase {
  margin: 1.6rem 0 0;
  background: var(--cabin);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 0.4rem;
}
.staircase svg { display: block; width: 100%; height: auto; }

.faq details {
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: 10px;
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
}
.faq summary {
  cursor: pointer;
  font-weight: 600;
  font-family: var(--display);
  list-style: none;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before {
  content: "▸";
  display: inline-block;
  margin-right: 0.45rem;
  color: var(--water);
  transition: transform 0.2s var(--ease);
}
.faq details[open] summary::before { transform: rotate(90deg); }
.faq details p { margin: 0.65rem 0 0.2rem; color: var(--mute); }

.close {
  background: var(--iron);
  color: #efe8d8;
  padding: 3.6rem 0;
  position: relative;
  overflow: hidden;
}
.close::before {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 36%;
  background: linear-gradient(180deg, transparent, rgba(30, 109, 108, 0.35));
}
.close h2 { color: #fbf6ea; }
.close .lede { color: #c9c0ae; }
.close .kicker { color: var(--brass); }
.close-inner { position: relative; z-index: 1; display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 2rem; align-items: center; }
.close .hero-actions .btn-ghost { color: #fbf6ea !important; border-color: var(--brass); }

.site-footer {
  background: #231f1c;
  color: #c9c0ae;
  padding: 2.4rem 0 1.6rem;
  font-size: 0.9rem;
}
.site-footer a { color: #efe8d8; text-decoration: none; }
.site-footer a:hover { color: var(--brass-hot); }
.foot-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr 1fr;
  gap: 1.4rem;
}
.site-footer h3 {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--brass);
  margin: 0 0 0.7rem;
}
.site-footer ul { list-style: none; margin: 0; padding: 0; }
.site-footer li { margin: 0.28rem 0; }
.site-footer .wordmark { color: #fbf6ea; margin-bottom: 0.5rem; }
.legal {
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(196, 160, 84, 0.2);
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem 1.2rem;
  font-size: 0.82rem;
}

.page { padding: 3.2rem 0 4rem; }
.page h1 { max-width: 22ch; }
.illust {
  margin: 0 0 1.6rem;
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  overflow: hidden;
}
.illust svg { display: block; width: 100%; height: auto; }
.doc {
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.1rem 1.2rem;
  margin: 0 0 1rem;
}
.doc pre, .logbook pre {
  margin: 0.6rem 0 0;
  white-space: pre-wrap;
  font-family: var(--mono);
  font-size: 0.82rem;
}
.article-list article,
.term {
  background: var(--log);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 1.05rem 1.15rem;
  margin: 0 0 0.85rem;
}
.term h3 { font-family: var(--mono); font-size: 0.95rem; letter-spacing: 0.04em; }

form {
  display: grid;
  gap: 0.45rem;
  max-width: 26rem;
  margin-top: 1.2rem;
}
label { font-size: 0.88rem; font-weight: 600; }
input, textarea, select {
  background: var(--log);
  border: 1px solid var(--oak);
  color: var(--ink);
  padding: 0.55rem 0.65rem;
  border-radius: 8px;
  font: inherit;
}
.swatches { display: flex; flex-wrap: wrap; gap: 0.7rem; margin: 1rem 0; }
.swatch {
  width: 4.4rem;
  height: 4.4rem;
  border-radius: 10px;
  border: 1px solid var(--rule);
  display: grid;
  align-content: end;
  padding: 0.3rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  color: #fbf6ea;
}

.reveal { opacity: 0; transform: translateY(14px); transition: opacity 0.5s var(--ease), transform 0.5s var(--ease); }
.reveal.is-in { opacity: 1; transform: none; }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes glow {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}
@keyframes drift {
  0%, 100% { transform: translateX(0); }
  50% { transform: translateX(10px); }
}
@keyframes fill { from { transform: scaleX(0.15); } to { transform: scaleX(1); } }
@keyframes current { from { background-position: 0 0; } to { background-position: 40px 0; } }

@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; }
  .wordmark .wheel, .lock-scene .wheel, .illust .wheel,
  .chip, .boat, .water-shim, .level span, .sluice-dot, .hero-band::after {
    animation: none;
  }
}

@media (max-width: 800px) {
  .wrap, .header-inner { width: min(var(--max), calc(100% - 1.5rem)); }
  .nav-toggle { display: inline-block; }
  .header-inner { flex-wrap: wrap; }
  .nav-list {
    display: none;
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    padding: 0.6rem 0 0.2rem;
  }
  .nav-list.is-open { display: flex; }
  .hero, .chamber, .loop, .close-inner, .foot-grid, .gauges {
    grid-template-columns: 1fr;
  }
  .chips { display: none; }
  .cand { grid-template-columns: 1fr 1fr; }
  h1 { font-size: 2rem; }
}
