/* Piano Lama — stage dark, felt rose, real ivory & ebony keys.
   authored by an adult beginner who learned between popup ads and vowed revenge. */

:root {
  --stage: #201d24;
  --stage-2: #2a2631;
  --ivory: #f2efe6;
  --ivory-down: #ddd8c8;
  --ebony: #17141a;
  --felt: #e05263;
  --felt-soft: rgba(224, 82, 99, 0.16);
  --fade: #9c93a5;
  --line: rgba(242, 239, 230, 0.14);
  --line-hard: rgba(242, 239, 230, 0.32);
  --wk: calc(100% / var(--wc, 17));
  --bk: calc(var(--wk) * 0.62);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--stage); }

body {
  background: var(--stage);
  color: var(--ivory);
  font-family: "Inter", -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

h1, h2, h3 { font-family: "Young Serif", Georgia, serif; font-weight: 400; letter-spacing: 0; line-height: 1.12; }

a { color: var(--felt); text-decoration: underline; text-underline-offset: 3px; }
a:hover { color: var(--ivory); }

/* ---------- topbar ---------- */
.topbar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 16px;
  padding: 12px 18px 8px;
  border-bottom: 2px solid var(--line-hard);
}
.wordmark { font-family: "Young Serif", serif; font-size: 1.35rem; color: var(--ivory); text-decoration: none; display: inline-flex; align-items: center; }
.wordmark img { display: block; height: 28px; width: auto; margin-right: 9px; }
.wordmark em { font-style: normal; color: var(--felt); }
.topbar .links { display: flex; flex-wrap: wrap; gap: 2px 16px; font-size: 0.86rem; }
.topbar .links a { color: var(--fade); text-decoration: none; }
.topbar .links a.here { color: var(--ivory); border-bottom: 3px solid var(--felt); }
.topbar .links a:hover { color: var(--felt); }

/* ---------- the instrument ---------- */
.stage { max-width: 1060px; margin: 0 auto; padding: 0 12px; }

.pianobox {
  border: 2px solid var(--line-hard);
  border-radius: 12px;
  background: var(--stage-2);
  padding: 12px;
  margin-top: 14px;
}

/* control rail above the keys — like the fallboard */
.fallboard {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: center;
  padding-bottom: 10px;
}
.pbtn {
  appearance: none;
  font-family: "Inter", sans-serif;
  font-weight: 600;
  font-size: 0.84rem;
  color: var(--ivory);
  background: var(--stage);
  border: 1.5px solid var(--line-hard);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
}
.pbtn:active { transform: translateY(2px); box-shadow: none; }
.pbtn.hot, .pbtn[aria-pressed="true"] { background: var(--felt); border-color: var(--felt); color: #fff; }
.pbtn:disabled { opacity: 0.4; cursor: default; }
.fallboard select {
  font-family: "Inter", sans-serif;
  font-size: 0.84rem;
  border: 1.5px solid var(--line-hard);
  border-radius: 8px;
  padding: 8px;
  background: var(--stage);
  color: var(--ivory);
}
.fallboard label { font-size: 0.8rem; color: var(--fade); display: inline-flex; gap: 6px; align-items: center; }
.fallboard input[type="checkbox"] { accent-color: var(--felt); width: 15px; height: 15px; }
.fallboard input[type="range"] { width: 90px; accent-color: var(--felt); }
.fallboard input[type="number"] {
  width: 58px;
  font-family: "Inter", sans-serif;
  font-size: 0.84rem;
  border: 1.5px solid var(--line-hard);
  border-radius: 8px;
  padding: 7px 8px;
  background: var(--stage);
  color: var(--ivory);
}
.fallboard .octlabel { font-size: 0.8rem; color: var(--fade); font-variant-numeric: tabular-nums; }
.fallctl { display: inline-flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding-left: 10px; border-left: 2px solid var(--line-hard); }

/* paste-a-sheet panel — slides in under the control rail */
.pastebox { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 2px 0 10px; }
.pastebox textarea {
  flex: 1 1 260px;
  min-height: 58px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
  font-size: 0.85rem;
  line-height: 1.5;
  border: 1.5px solid var(--line-hard);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--stage);
  color: var(--ivory);
  resize: vertical;
}
.pastebox textarea::placeholder { color: var(--fade); opacity: 0.8; }
.pastehint { font-size: 0.8rem; color: var(--felt); flex-basis: 100%; }

/* falling-notes canvas — sits on top of the keys, notes land on the felt strip */
.fallcanvas {
  display: block;
  width: 100%;
  height: 26vh;
  min-height: 150px;
  max-height: 260px;
  background: linear-gradient(var(--stage), var(--stage-2));
  border: 2px solid var(--line-hard);
  border-bottom: 0;
  border-radius: 10px 10px 0 0;
  touch-action: none;
}

/* the keys — white keys on a grid, blacks absolutely placed over them */
.keys {
  position: relative;
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  height: 34vh;
  min-height: 200px;
  max-height: 340px;
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: var(--ebony);
  padding-top: 6px;               /* the felt strip */
  box-shadow: inset 0 6px 0 var(--felt);
}
.key { appearance: none; border: 0; cursor: pointer; position: relative; }
.key.white {
  background: linear-gradient(#ffffff, var(--ivory) 70%);
  border-left: 1px solid #c9c4b4;
  border-radius: 0 0 5px 5px;
  z-index: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding-bottom: 8px;
  gap: 3px;
}
.key.white.down { background: linear-gradient(var(--ivory-down), var(--ivory-down)); transform: translateY(1px); }
.key.black {
  position: absolute;
  top: 6px;
  width: var(--bk);
  height: 58%;
  background: linear-gradient(#3a3440, var(--ebony) 30%);
  border-radius: 0 0 4px 4px;
  z-index: 2;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}
.key.black.down { background: #241f29; transform: translateY(2px); box-shadow: none; }
.key .nname { font-size: 0.6rem; color: #8d8878; font-weight: 600; }
.key .kname {
  font-size: 0.62rem;
  font-weight: 700;
  color: #b0aa98;
  border: 1px solid #c9c4b4;
  border-radius: 4px;
  padding: 0 4px;
  min-width: 16px;
  text-align: center;
}
.key.black .kname { color: #7d7589; border-color: #4a4454; }
.key.next { outline: 3px solid var(--felt); outline-offset: -3px; }
.key.next:after {
  content: "";
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--felt);
  animation: pulse 0.9s infinite;
}
@keyframes pulse { 50% { opacity: 0.3; } }
@media (prefers-reduced-motion: reduce) { .key.next:after { animation: none; } }

/* under-keys strip */
.underkeys {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
  align-items: center;
  padding-top: 10px;
  font-size: 0.8rem;
  color: var(--fade);
}
.underkeys b { color: var(--ivory); }

/* ---------- prose ---------- */
.deskcol { max-width: 720px; margin: 0 auto; padding: 0 18px; }

.opening { padding: 22px 0 4px; }
.opening h1 { font-size: 1.9rem; }
@media (min-width: 560px) { .opening h1 { font-size: 2.5rem; } }
.opening .why { margin-top: 10px; font-size: 0.97rem; color: var(--fade); }
.opening .why b { color: var(--ivory); }

.sticker {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 600;
  border: 2px solid var(--line-hard);
  background: var(--stage-2);
  padding: 3px 10px;
  border-radius: 6px;
  transform: rotate(-1.3deg);
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.5);
  margin: 0 6px 4px 0;
  white-space: nowrap;
}
.sticker.tilt { transform: rotate(1.1deg); }
.sticker.hot { background: var(--felt); border-color: var(--felt); color: #fff; }

.makernote {
  border: 2px solid var(--line-hard);
  border-radius: 10px;
  background: var(--stage-2);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45);
  padding: 16px 18px;
  margin: 26px 0;
  transform: rotate(0.3deg);
}
.makernote .sig { font-size: 0.8rem; color: var(--fade); margin-top: 8px; font-style: italic; }

section { margin-top: 42px; }
section > h2 { font-size: 1.4rem; margin-bottom: 12px; }
section > h2 .u { border-bottom: 3px solid var(--felt); padding-bottom: 2px; }
section p { margin-bottom: 12px; }
.fade { color: var(--fade); }
section ul, section ol { margin: 0 0 12px 22px; }
section li { margin-bottom: 7px; }

.loglist { font-size: 0.86rem; list-style: none; margin-left: 0 !important; }
.loglist li { padding: 6px 0; border-bottom: 1.5px dashed var(--line); margin: 0 !important; }
.loglist .v { color: var(--felt); font-weight: 700; margin-right: 10px; }

details { border: 2px solid var(--line); border-radius: 8px; background: var(--stage-2); padding: 10px 14px; margin-bottom: 8px; }
details summary { cursor: pointer; font-weight: 600; }
details p { margin-top: 8px; color: var(--fade); font-size: 0.93rem; }

.elsewhere { font-size: 0.95rem; }
.elsewhere li { margin-bottom: 10px; }
.elsewhere .what { color: var(--fade); }

kbd {
  font-size: 0.75rem;
  border: 1.5px solid var(--line-hard);
  border-radius: 5px;
  padding: 1px 7px;
  background: var(--stage-2);
}

[hidden] { display: none !important; }

/* chord page bits */
.chordpick { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chordpick select { font-size: 1rem; padding: 10px; border-radius: 8px; border: 1.5px solid var(--line-hard); background: var(--stage-2); color: var(--ivory); }

/* ---------- blog ---------- */
.postlist a {
  display: block;
  border: 2px solid var(--line-hard);
  border-radius: 10px;
  background: var(--stage-2);
  padding: 14px 16px;
  margin-bottom: 10px;
  color: var(--ivory);
  text-decoration: none;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.45);
}
.postlist a:hover { box-shadow: 1px 1px 0 rgba(0, 0, 0, 0.45); transform: translate(2px, 2px); }
.postlist b { font-family: "Young Serif", serif; font-weight: 400; font-size: 1.1rem; display: block; margin-bottom: 4px; }
.postlist span { color: var(--fade); font-size: 0.88rem; }
.postlist time { display: block; font-size: 0.72rem; color: var(--fade); margin-top: 8px; }

article.post { padding-top: 26px; }
article.post h1 { font-size: 1.8rem; margin-bottom: 6px; }
article.post .meta { color: var(--fade); font-size: 0.76rem; margin-bottom: 20px; }
article.post h2 { font-size: 1.25rem; margin: 26px 0 10px; }
article.post p { margin-bottom: 13px; }
article.post figure { margin: 22px 0; border: 2px solid var(--line-hard); border-radius: 10px; overflow: hidden; box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.45); }
article.post figure svg { display: block; width: 100%; height: auto; }
article.post figcaption { font-size: 0.76rem; color: var(--fade); padding: 8px 12px; border-top: 1.5px dashed var(--line); background: var(--stage-2); }
article.post ul, article.post ol { margin: 0 0 13px 22px; }
article.post li { margin-bottom: 6px; }

/* ---------- footer ---------- */
footer {
  margin-top: 56px;
  border-top: 2px solid var(--line-hard);
  padding: 18px 18px 34px;
  font-size: 0.82rem;
  color: var(--fade);
}
footer .cols { display: flex; flex-wrap: wrap; gap: 4px 18px; margin-bottom: 10px; }
footer a { color: var(--fade); text-decoration: none; }
footer a:hover { color: var(--felt); }

.plain { padding-top: 30px; }
.plain h1 { font-size: 1.7rem; margin-bottom: 14px; }
.plain h2 { font-size: 1.15rem; margin: 22px 0 8px; }
.plain p { margin-bottom: 12px; color: var(--fade); }
.plain p b { color: var(--ivory); }

/* ---------- responsive overrides — keep last so they win the cascade ---------- */
/* phones: tighten the control rail so the keys stay above the fold */
@media (max-width: 559px) {
  .topbar { padding: 8px 12px 6px; }
  .pianobox { padding: 8px; margin-top: 8px; }
  .fallboard { gap: 5px 8px; padding-bottom: 7px; }
  .pbtn, .fallboard select, .fallboard input[type="number"] { font-size: 0.76rem; padding: 6px 9px; }
  .fallboard input[type="number"] { width: 50px; }
  .fallboard input[type="range"] { width: 70px; }
  .fallboard label { font-size: 0.74rem; gap: 4px; }
  /* portrait keys were spaghetti — a tapping keyboard doesn't need concert depth */
  .keys { height: 26vh; min-height: 180px; max-height: 240px; }
}

/* phone turned sideways: the piano is the point, so the piano gets the screen.
   controls become one scrollable strip, keys take the height. */
@media (max-height: 500px) {
  .topbar { padding: 5px 12px 4px; }
  .wordmark { font-size: 1.05rem; }
  .wordmark img { height: 20px; margin-right: 7px; }
  .topbar .links { font-size: 0.78rem; }
  .pianobox { padding: 6px 8px; margin-top: 6px; }
  .fallboard {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    gap: 6px;
    padding-bottom: 6px;
    scrollbar-width: thin;
  }
  .fallboard > * { flex: 0 0 auto; }
  .fallboard label { white-space: nowrap; font-size: 0.74rem; }
  .pbtn, .fallboard select, .fallboard input[type="number"] { font-size: 0.76rem; padding: 5px 9px; white-space: nowrap; }
  .fallboard input[type="number"] { width: 50px; }
  .fallboard input[type="range"] { width: 70px; }
  .fallcanvas { height: 20vh; min-height: 80px; }
  .keys { height: 56vh; min-height: 150px; max-height: none; }
  .underkeys { font-size: 0.72rem; gap: 3px 10px; padding-top: 6px; }
  .pastebox textarea { min-height: 40px; }
}

/* the one-line rotate nudge, portrait phones only (js decides when) */
.rotatehint { color: var(--felt); font-weight: 600; }
.rotatehint button {
  font: inherit;
  font-size: 0.72rem;
  color: var(--fade);
  background: none;
  border: 1.5px solid var(--line-hard);
  border-radius: 6px;
  padding: 1px 8px;
  margin-left: 6px;
  cursor: pointer;
}
