/* Espresso Robot Guide: espresso browns + Android green, Material-style surfaces */
:root {
  --bg: #17100c;
  --surface: #211712;
  --surface-2: #2c2019;
  --surface-3: #382a21;
  --line: #4a382c;
  --ink: #f4ece3;
  --muted: #b8a695;
  --crema: #e2a95c;
  --droid: #3ddc84;
  --droid-ink: #06301a;
  --danger: #ff8a7a;
  --code-bg: #120c09;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
  --display: "Sora", system-ui, sans-serif;
  --body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
:root[data-theme="light"] {
  --bg: #f5f2ef;
  --surface: #ffffff;
  --surface-2: #efe9e4;
  --surface-3: #e4dbd3;
  --line: #d6cabf;
  --ink: #2a1c14;
  --muted: #6d5a4c;
  --crema: #a8631a;
  --droid: #0f9d58;
  --droid-ink: #ffffff;
  --danger: #b3261e;
  --code-bg: #2a1c14;
  --shadow: 0 8px 24px rgba(60, 30, 10, 0.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.65 var(--body);
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
  -webkit-font-smoothing: antialiased;
}
:focus-visible { outline: 3px solid var(--droid); outline-offset: 2px; border-radius: 6px; }
a { color: var(--droid); }
code {
  font: 0.86em var(--mono);
  background: var(--surface-2);
  padding: 0.12em 0.4em;
  border-radius: 6px;
}

/* scroll progress */
#progress {
  position: fixed; top: 0; left: 0; right: 0; height: 4px; z-index: 50;
  background: linear-gradient(90deg, var(--crema), var(--droid));
  transform-origin: 0 50%; transform: scaleX(0);
}

/* layout */
.layout { display: flex; min-height: 100vh; }
nav.side {
  width: 264px; flex-shrink: 0;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 24px 14px;
  background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 4px;
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 17px var(--display); padding: 4px 10px 18px; }
.brand .logo {
  width: 34px; height: 34px; border-radius: 12px; display: grid; place-items: center;
  background: var(--droid); color: var(--droid-ink); font-size: 18px;
}
nav.side a.nav-link {
  position: relative; overflow: hidden;
  display: block; padding: 10px 16px; border-radius: 999px;
  color: var(--muted); text-decoration: none; font-weight: 500; font-size: 15px;
  transition: background 0.25s var(--ease), color 0.25s var(--ease), padding-left 0.25s var(--ease);
}
nav.side a.nav-link:hover { background: var(--surface-2); color: var(--ink); padding-left: 20px; }
nav.side a.nav-link.active { background: color-mix(in srgb, var(--droid) 22%, transparent); color: var(--ink); font-weight: 700; }
.side-foot { margin-top: auto; padding: 14px 6px 0; display: flex; flex-direction: column; gap: 10px; }
.side-byline { margin: 0; font-size: 12px; color: var(--muted); padding: 0 6px; }
.side-byline strong { color: var(--ink); }
.icon-btn {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--ink);
  border-radius: 999px; padding: 9px 16px; font: 600 14px var(--body); cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--ease);
}
.icon-btn:hover { background: var(--surface-3); }
.icon-btn:active { transform: scale(0.96); }

/* mobile nav: hamburger + drawer + scrim (keeps the rail usable at any width) */
.menu-btn {
  display: none; position: fixed; top: 16px; left: 16px; z-index: 55;
  width: 44px; height: 44px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--surface); box-shadow: var(--shadow); cursor: pointer;
  flex-direction: column; align-items: center; justify-content: center; gap: 5px;
}
.menu-btn span { width: 20px; height: 2px; background: var(--ink); border-radius: 2px; transition: transform 0.3s var(--ease), opacity 0.3s var(--ease); }
.menu-btn[aria-expanded="true"] span:nth-child(1) { transform: translateY(7px) rotate(45deg); }
.menu-btn[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.menu-btn[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }
.scrim {
  display: none; position: fixed; inset: 0; z-index: 45;
  background: rgba(10, 6, 4, 0.55); opacity: 0; transition: opacity 0.3s var(--ease);
}
.scrim.show { display: block; opacity: 1; }

main { flex: 1; min-width: 0; padding: 28px clamp(16px, 4vw, 56px) 120px; max-width: 1040px; margin: 0 auto; width: 100%; }

/* footer */
.page-foot {
  margin-top: 72px; padding-top: 24px; border-top: 1px solid var(--line);
  color: var(--muted); font-size: 14px; line-height: 1.7;
}
.page-foot strong { color: var(--ink); }
.page-foot p { margin: 0 0 4px; max-width: none; }
.page-foot .muted { font-size: 13px; }
.byline { margin: -8px 0 18px; color: var(--muted); font-size: 14px; }
.byline strong { color: var(--ink); }

/* hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: 36px; padding: clamp(24px, 4vw, 48px);
  background:
    radial-gradient(circle at 85% 10%, color-mix(in srgb, var(--crema) 26%, transparent), transparent 55%),
    linear-gradient(160deg, var(--surface-2), var(--surface));
  border: 1px solid var(--line);
  display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center;
  animation: heroIn 0.9s var(--ease) both;
}
@keyframes heroIn { from { opacity: 0; transform: translateY(18px) scale(0.985); } to { opacity: 1; transform: none; } }
.hero h1 { font: 800 clamp(2.2rem, 5vw, 3.6rem)/1.02 var(--display); margin: 0 0 14px; letter-spacing: -0.03em; }
.hero p.lead { color: var(--muted); font-size: 1.1rem; max-width: 34ch; margin: 0 0 22px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 22px; }
.chip {
  position: relative; overflow: hidden;
  border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px;
  color: var(--ink); text-decoration: none; font-size: 14px; font-weight: 600; background: var(--surface);
  transition: background 0.2s, border-color 0.2s, transform 0.2s var(--ease);
}
.chip:hover { border-color: var(--droid); transform: translateY(-2px); }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.fab {
  position: relative; overflow: hidden;
  display: inline-flex; align-items: center; gap: 10px;
  border: 0; border-radius: 20px; padding: 16px 24px;
  background: var(--droid); color: var(--droid-ink);
  font: 700 16px var(--display); cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--droid) 40%, transparent);
  transition: transform 0.2s var(--ease), box-shadow 0.2s, border-radius 0.3s var(--ease);
}
.fab:hover { border-radius: 26px; box-shadow: 0 10px 26px color-mix(in srgb, var(--droid) 55%, transparent); }
.fab:active { transform: scale(0.95); }
.fab[disabled] { opacity: 0.6; cursor: progress; }
.text-btn {
  position: relative; overflow: hidden; border: 0; background: transparent; color: var(--ink);
  padding: 14px 16px; border-radius: 16px; font: 600 15px var(--body); cursor: pointer;
}
.text-btn:hover { background: var(--surface-3); }

.stage { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.cup-wrap { display: grid; place-items: center; }
svg.cup { width: min(100%, 300px); height: auto; overflow: visible; }
.cup .glass { fill: color-mix(in srgb, var(--ink) 8%, transparent); stroke: var(--ink); stroke-width: 5; stroke-linejoin: round; }
.cup .handle { fill: none; stroke: var(--ink); stroke-width: 10; stroke-linecap: round; }
.cup .saucer { fill: var(--surface-3); }
.cup .liquid { transform: translateY(calc((1 - var(--fill, 0)) * 132px)); transition: transform 2.6s cubic-bezier(0.3, 0.6, 0.3, 1); }
.cup .coffee { fill: #4a2412; }
.cup .crema { fill: var(--crema); }
.cup .stream { stroke: #4a2412; stroke-width: 5; stroke-linecap: round; stroke-dasharray: 6 8; opacity: 0; }
.cup.pouring .stream { opacity: 1; animation: drip 0.5s linear infinite; }
@keyframes drip { to { stroke-dashoffset: -28; } }
.cup .porta { fill: var(--surface-3); stroke: var(--line); stroke-width: 2; }
.cup .antenna { stroke: var(--ink); stroke-width: 4; stroke-linecap: round; }
.cup .bulb { fill: var(--droid); transform-origin: 84px 64px; animation: pulse 2.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.35); filter: drop-shadow(0 0 6px var(--droid)); } }
.cup .steam path { fill: none; stroke: var(--muted); stroke-width: 4; stroke-linecap: round; opacity: 0; }
.cup.done .steam path { animation: steam 2.8s ease-in-out infinite; }
.cup.done .steam path:nth-child(2) { animation-delay: 0.5s; }
.cup.done .steam path:nth-child(3) { animation-delay: 1.1s; }
@keyframes steam { 0% { opacity: 0; transform: translateY(8px); } 40% { opacity: 0.7; } 100% { opacity: 0; transform: translateY(-18px); } }
.badge {
  justify-self: center; margin-top: -6px; padding: 6px 16px; border-radius: 999px;
  font: 700 13px var(--mono); background: var(--surface-3); color: var(--muted);
  transition: background 0.3s, color 0.3s, transform 0.4s var(--ease);
}
.badge.pass { background: var(--droid); color: var(--droid-ink); transform: scale(1.12); }

.term {
  background: var(--code-bg); border: 1px solid var(--line); border-radius: 18px;
  padding: 14px 16px; font: 13px/1.9 var(--mono); color: #eadfd2;
}
.term .cmd { color: var(--muted); }
.term .step { display: flex; align-items: center; gap: 10px; opacity: 0.45; transition: opacity 0.3s, transform 0.3s var(--ease); }
.term .step .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted); flex-shrink: 0; }
.term .step.run { opacity: 1; transform: translateX(4px); }
.term .step.run .dot { border-color: var(--crema); border-top-color: transparent; animation: spin 0.7s linear infinite; }
.term .step.ok { opacity: 1; }
.term .step.ok .dot { border-color: var(--droid); background: var(--droid); position: relative; animation: none; }
.term .step.ok .dot::after { content: ""; position: absolute; left: 3px; top: 0; width: 3px; height: 7px; border: solid var(--droid-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
@keyframes spin { to { transform: rotate(360deg); } }
.term .result { color: var(--droid); font-weight: 700; height: 0; opacity: 0; overflow: hidden; transition: opacity 0.4s, height 0.4s var(--ease); }
.term .result.show { height: 26px; opacity: 1; }
.term small { color: var(--muted); display: block; margin-top: 4px; font-size: 11px; }

/* sections */
section { margin-top: 56px; }
h2 {
  font: 800 clamp(1.5rem, 3vw, 2rem)/1.15 var(--display); letter-spacing: -0.02em;
  margin: 0 0 16px; display: flex; align-items: center; gap: 12px;
}
h2::before { content: ""; width: 12px; height: 28px; border-radius: 6px; background: linear-gradient(var(--droid), var(--crema)); flex-shrink: 0; }
h3 { font: 700 1.15rem var(--display); margin: 30px 0 10px; }
p, li { max-width: 74ch; }
pre { margin: 0; }

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

/* tables */
.table-wrap { overflow-x: auto; margin: 14px 0; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { background: var(--surface-2); font: 700 13px var(--display); position: sticky; top: 0; }
tbody tr { transition: background 0.2s; }
tbody tr:hover { background: color-mix(in srgb, var(--droid) 9%, transparent); }
tbody tr:last-child td { border-bottom: 0; }
tr.hide { display: none; }

.filter {
  display: flex; align-items: center; gap: 10px; margin: 14px 0 0;
  padding: 0 18px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.filter:focus-within { border-color: var(--droid); box-shadow: 0 0 0 4px color-mix(in srgb, var(--droid) 22%, transparent); }
.filter input { flex: 1; border: 0; background: transparent; color: var(--ink); padding: 13px 0; font: 500 15px var(--body); outline: none; }
.filter svg { width: 18px; height: 18px; stroke: var(--muted); fill: none; stroke-width: 2; }
.empty { display: none; color: var(--muted); padding: 18px 4px; }
.empty.show { display: block; }

/* code */
.codeblock { position: relative; margin: 14px 0; border-radius: 18px; overflow: hidden; background: var(--code-bg); border: 1px solid var(--line); }
.codebar { display: flex; justify-content: space-between; align-items: center; padding: 8px 10px 8px 16px; background: rgba(255,255,255,0.04); font: 12px var(--mono); color: #b8a695; }
.copy {
  position: relative; overflow: hidden; border: 0; border-radius: 999px; padding: 6px 14px;
  background: rgba(255,255,255,0.08); color: #f4ece3; font: 600 12px var(--body); cursor: pointer;
  transition: background 0.2s, transform 0.2s var(--ease);
}
.copy:hover { background: rgba(255,255,255,0.16); }
.copy.ok { background: var(--droid); color: var(--droid-ink); transform: scale(1.06); }
.codeblock pre { padding: 16px 18px; overflow-x: auto; }
.codeblock pre code { background: none; padding: 0; font: 13px/1.6 var(--mono); color: #eadfd2; }
.tk-c { color: #8c7a6b; font-style: italic; }
.tk-s { color: #9be5a4; }
.tk-k { color: #f2a65a; }
.tk-a { color: #7fc8ff; }
.tk-t { color: #e8c9a0; }
.tk-n { color: #d9a5ff; }

/* tabs */
.tabs { margin: 16px 0; }
.tablist { display: flex; gap: 6px; padding: 5px; border-radius: 999px; background: var(--surface-2); width: fit-content; max-width: 100%; overflow-x: auto; position: relative; }
.tab {
  position: relative; overflow: hidden; border: 0; background: transparent; color: var(--muted);
  padding: 9px 18px; border-radius: 999px; font: 600 14px var(--mono); cursor: pointer; white-space: nowrap;
  transition: color 0.25s, background 0.25s;
}
.tab[aria-selected="true"] { background: var(--droid); color: var(--droid-ink); }
.tab:not([aria-selected="true"]):hover { color: var(--ink); background: var(--surface-3); }
.tabpanel { display: none; }
.tabpanel.active { display: block; animation: panelIn 0.4s var(--ease); }
@keyframes panelIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* accordion */
.acc-list { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.acc { border: 1px solid var(--line); border-radius: 18px; background: var(--surface); overflow: hidden; transition: border-color 0.25s, background 0.25s; }
.acc.hide { display: none; }
.acc.open { border-color: color-mix(in srgb, var(--droid) 60%, var(--line)); background: var(--surface-2); }
.acc-head {
  width: 100%; display: flex; justify-content: space-between; align-items: center; gap: 16px; text-align: left;
  border: 0; background: transparent; color: var(--ink); padding: 16px 20px; font: 600 15px/1.4 var(--body); cursor: pointer;
}
.acc-head::after {
  content: ""; width: 10px; height: 10px; flex-shrink: 0;
  border: solid var(--muted); border-width: 0 2.5px 2.5px 0; transform: rotate(45deg) translate(-2px, -2px);
  transition: transform 0.35s var(--ease), border-color 0.2s;
}
.acc.open .acc-head::after { transform: rotate(225deg); border-color: var(--droid); }
.acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.4s var(--ease); }
.acc.open .acc-body { grid-template-rows: 1fr; }
.acc-inner { overflow: hidden; padding: 0 20px; }
.acc.open .acc-inner { padding-bottom: 18px; }
.acc-inner .lbl { display: inline-block; font: 700 12px var(--display); color: var(--crema); margin: 6px 0 2px; }
.acc-inner p { margin: 0 0 8px; }

/* checklist */
.check-head { display: flex; align-items: center; gap: 16px; margin-bottom: 8px; }
.ring { width: 54px; height: 54px; flex-shrink: 0; }
.ring circle { fill: none; stroke-width: 6; }
.ring .bg { stroke: var(--surface-3); }
.ring .fg { stroke: var(--droid); stroke-linecap: round; stroke-dasharray: 138.2; stroke-dashoffset: 138.2; transform: rotate(-90deg); transform-origin: 50% 50%; transition: stroke-dashoffset 0.6s var(--ease); }
.ring text { font: 700 14px var(--display); fill: var(--ink); text-anchor: middle; dominant-baseline: central; }
ul.check { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }
ul.check li {
  display: flex; gap: 14px; align-items: flex-start; cursor: pointer; max-width: none;
  padding: 14px 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  transition: background 0.25s, border-color 0.25s, transform 0.2s var(--ease);
}
ul.check li:hover { transform: translateX(4px); border-color: var(--muted); }
ul.check li .box {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--muted); flex-shrink: 0; margin-top: 2px; position: relative;
  transition: background 0.25s, border-color 0.25s, transform 0.3s var(--ease);
}
ul.check li.done { background: color-mix(in srgb, var(--droid) 12%, var(--surface)); border-color: color-mix(in srgb, var(--droid) 55%, var(--line)); }
ul.check li.done .box { background: var(--droid); border-color: var(--droid); transform: scale(1.1); }
ul.check li.done .box::after { content: ""; position: absolute; left: 6px; top: 1px; width: 6px; height: 12px; border: solid var(--droid-ink); border-width: 0 3px 3px 0; transform: rotate(45deg); }
ul.check li.done .txt { color: var(--muted); }

.note { border-radius: 18px; padding: 14px 18px; background: color-mix(in srgb, var(--crema) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--crema) 50%, var(--line)); }

/* snackbar + top button + beans */
#snack {
  position: fixed; left: 50%; bottom: 28px; z-index: 60; transform: translate(-50%, 90px);
  background: var(--ink); color: var(--bg); padding: 13px 22px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow);
  transition: transform 0.4s var(--ease); pointer-events: none;
}
#snack.show { transform: translate(-50%, 0); }
#top {
  position: fixed; right: 24px; bottom: 24px; z-index: 40; border: 0; border-radius: 18px; padding: 14px 20px;
  background: var(--crema); color: #2a1408; font: 700 14px var(--display); cursor: pointer; box-shadow: var(--shadow);
  transform: translateY(120px); transition: transform 0.45s var(--ease);
}
#top.show { transform: none; }
.bean {
  position: fixed; width: 10px; height: 15px; border-radius: 50%; background: #5a2e17; z-index: 70; pointer-events: none;
  box-shadow: inset -2px 0 0 #3a1a0b; animation: bean 1.3s var(--ease) forwards;
}
@keyframes bean { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
.ripple { position: absolute; border-radius: 50%; background: rgba(255,255,255,0.35); transform: scale(0); animation: ripple 0.6s linear; pointer-events: none; }
@keyframes ripple { to { transform: scale(4); opacity: 0; } }

/* --- scalable breakpoints: ultra-wide down to small phones --- */

/* ultra-wide: let content breathe instead of stretching line-length */
@media (min-width: 1600px) {
  main { max-width: 1180px; }
  nav.side { width: 288px; }
}

/* small laptop / tablet landscape: nav rail narrows before it disappears */
@media (max-width: 1180px) and (min-width: 901px) {
  nav.side { width: 216px; padding: 20px 10px; }
  main { padding-left: clamp(16px, 3vw, 36px); padding-right: clamp(16px, 3vw, 36px); }
  .hero { grid-template-columns: 1fr; }
  .stage { max-width: 420px; margin: 0 auto; width: 100%; }
}

/* tablet portrait and phones: rail becomes an off-canvas drawer */
@media (max-width: 900px) {
  .menu-btn { display: flex; }
  .layout { display: block; }
  nav.side {
    position: fixed; top: 0; left: 0; z-index: 50;
    width: min(78vw, 300px); height: 100vh;
    transform: translateX(-100%);
    transition: transform 0.35s var(--ease);
    box-shadow: var(--shadow);
  }
  nav.side.open { transform: translateX(0); }
  main { max-width: none; padding-top: 72px; }
  .hero { grid-template-columns: 1fr; border-radius: 28px; }
  .stage { max-width: 460px; margin: 0 auto; width: 100%; }
}

/* phones: tighten spacing and stack the hero controls */
@media (max-width: 560px) {
  main { padding-left: 16px; padding-right: 16px; padding-bottom: 100px; }
  .hero { padding: 20px; border-radius: 22px; }
  .btn-row { flex-direction: column; align-items: stretch; }
  .fab, .text-btn { justify-content: center; }
  section { margin-top: 40px; }
  #top { right: 16px; bottom: 16px; padding: 12px 16px; }
  .term { font-size: 12px; }
}

/* very small phones */
@media (max-width: 360px) {
  .hero h1 { font-size: 1.8rem; }
  .chips { gap: 6px; }
  .chip { font-size: 12.5px; padding: 5px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
  .reveal { opacity: 1; transform: none; }
}
