/* Aesthetic options (v0.4). Each block is keyed off a data attribute that config.js sets on <html>. */

/* Shared bits */
.ride { display: inline-block; width: .55em; height: 1.05em; margin-left: 1px; vertical-align: -.17em; background: currentColor; animation: blink 1.05s steps(1) infinite; }
.ghost { opacity: .28; }
.reserve { visibility: hidden; }
.lift { position: fixed; z-index: 30; pointer-events: none; margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.lift code { font-family: var(--f-system); }

/* ── User's previous messages ── */
[data-user-style="shell"] .msg.user .who,
[data-user-style="prompt"] .msg.user .who { visibility: hidden; }
[data-user-style="shell"] .msg.user .body::before { content: "> "; color: var(--faint); }
[data-user-style="prompt"] .msg.user .body::before { content: "you@buddy:~$ "; color: #8a7148; font: .9em var(--f-system); }
[data-user-style="reverse"] .msg.user .body > * {
  background: var(--c-user); color: var(--bg); padding: 1px 5px; border-radius: 2px;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}

/* ── Composer: inline shell line ── */
[data-composer-style="inline"] .input { border: 0; padding-left: 0; padding-right: 0; }
[data-composer-style="inline"] .input::before { content: "$ "; color: var(--faint); font-family: var(--f-system); }
[data-composer-style="inline"] .input::after {
  content: ""; display: inline-block; width: .55em; height: 1.05em; margin-left: 1px; vertical-align: -.17em;
  background: var(--c-user); animation: blink 1.05s steps(1) infinite;
}
[data-composer-style="inline"] .send { display: none; }
.input.flash > span:not(.ghost), .input.flash > code { background: var(--c-user); color: var(--bg); }

/* ── Composer: send control ── */
[data-composer-send="keycap"] .send { font: 500 16px var(--f-system); min-width: 52px; padding: 0 12px; }
[data-composer-send="inside"] .input-row { position: relative; }
[data-composer-send="inside"] .input { padding-right: 96px; }
[data-composer-send="inside"] .send {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  font: 11px var(--f-system); padding: 3px 8px; border-radius: 5px;
}
[data-composer-send="inside"] .send:not(:disabled) { background: transparent; color: var(--c-user); border-color: var(--c-user); }
[data-composer-send="breathe"] .send { display: none; }
[data-composer-send="breathe"] .input-row.ready .input { animation: breathe-border 2.2s ease-in-out infinite; }
@keyframes breathe-border { 50% { border-color: var(--c-user); box-shadow: 0 0 0 4px rgba(240,194,122,.08); } }

/* ── Before Buddy speaks ── */
.msg.buddy.pre .body { font: var(--s-buddy)/1.55 var(--f-buddy); color: var(--c-buddy); }
.msg.buddy.pre .thinking { color: var(--c-thought); font-style: italic; animation: breathe 2.2s ease-in-out infinite; }

/* ── Buddy's thoughts ── */
[data-thought-style="hash"] .msg.buddy.thought .body,
[data-thought-style="comment"] .msg.buddy.thought .body { font: var(--s-system)/1.6 var(--f-system); font-style: normal; }
[data-thought-style="hash"] .msg.buddy.thought .body::before { content: "# "; }
[data-thought-style="comment"] .msg.buddy.thought .body::before { content: "/* "; }
[data-thought-style="comment"] .msg.buddy.thought .body::after { content: " */"; }
[data-thought-style="ruled"] .msg.buddy.thought .body { font-size: calc(var(--s-buddy) * .86); border-left: 1px solid #2e2e33; padding-left: 12px; margin-left: 2px; }

/* ── Tool calls ── */
[data-tool-style="dot"] .msg.buddy.tool .body::before { content: "⏺ "; color: #7fb08f; }
[data-tool-style="dot"] .msg.buddy.tool code,
[data-tool-style="box"] .msg.buddy.tool code,
[data-tool-style="card"] .msg.buddy.tool code { background: none; border: 0; padding: 0; font-size: var(--s-system); }
[data-tool-style="box"] .msg.buddy.tool .body {
  justify-self: start; position: relative; margin-top: 8px; padding: 8px 12px 6px;
  border: 1px solid #3a3a40; border-radius: 8px;
}
[data-tool-style="box"] .msg.buddy.tool .body::before {
  content: "tool"; position: absolute; top: -.75em; left: 10px; padding: 0 6px; background: var(--bg);
  font: 11px/1.4 var(--f-system); color: var(--dim);
}
[data-tool-style="card"] .msg.buddy.tool .body { justify-self: start; border: 1px solid var(--line); margin-top: 4px; }
[data-tool-style="card"] .msg.buddy.tool .body::before {
  content: "tool"; display: block; padding: 3px 10px; background: #17171b; border-bottom: 1px solid var(--line);
  font: 11px/1.5 var(--f-system); color: var(--dim);
}
[data-tool-style="card"] .msg.buddy.tool code { display: block; padding: 6px 10px; }

/* ── System notices ── */
.msg.system .ts, .msg.system .tag, .msg.system .bang { display: none; }
[data-system-time="true"] .msg.system .ts { display: inline; color: var(--faint); }
[data-system-tags="true"] .msg.system .tag { display: inline; color: var(--dim); }
[data-system-tags="true"] .msg.system.error .tag { color: var(--error); }
[data-system-stderr="true"] .msg.system.error .bang { display: inline; color: var(--error); font-weight: 500; }
[data-system-stderr="true"] .msg.system.error .body { border-left: 2px solid var(--error); padding-left: 10px; }
[data-system-align="centred"] .msg.system { grid-template-columns: 1fr; text-align: center; }
[data-system-align="centred"] .msg.system .who { display: none; }
[data-system-align="centred"] .msg.system .body { font-size: calc(var(--s-system) * .92); }

/* ── Turn boundaries ── */
.history { counter-reset: turn; }
.turn { counter-increment: turn; position: relative; }
.pill { display: none; }
[data-turn-divider="space"] .turn,
[data-turn-divider="pill"] .turn,
[data-turn-divider="ascii"] .turn,
[data-turn-divider="counter"] .turn { border-top-color: transparent; }
[data-turn-divider="space"] .turn { padding-top: 22px; }
[data-turn-divider="pill"] .pill {
  display: block; width: fit-content; margin: 12px auto 4px; padding: 1px 10px; border: 1px solid var(--line);
  border-radius: 999px; font: 11px var(--f-system); color: var(--dim); opacity: var(--focus-dim);
}
[data-turn-divider="ascii"] .turn:not(:first-child)::before,
[data-turn-divider="counter"] .turn:not(:first-child)::before {
  display: block; overflow: hidden; white-space: nowrap; height: 1.4em; margin: -6px 0 4px;
  font: 12px/1.4 var(--f-system); color: var(--faint);
}
[data-turn-divider="ascii"] .turn:not(:first-child)::before { content: "────────────────────────────────────────────────────────────────────────────────────────────────"; }
[data-turn-divider="counter"] .turn:not(:first-child)::before { content: "── " counter(turn) " ──"; text-align: center; }
[data-turn-divider="numbered"] .turn:not(:first-child)::before {
  content: counter(turn); position: absolute; top: -.75em; left: 0; padding-right: 6px; background: var(--bg);
  font: 10px/1.4 var(--f-system); color: var(--faint);
}

/* ── Aging of older turns ── */
[data-age-style="none"] .turn { opacity: 1; }
[data-age-style="blur"] .turn { transition: opacity .35s, filter .35s; }
[data-age-style="blur"] .turn:not(.focus) { filter: blur(1.1px); }

/* ── Whole-screen mood ── */
.fx > div { position: fixed; inset: 0; pointer-events: none; z-index: 20; display: none; }
[data-fx-scanlines="true"] .fx-scan {
  display: block; background: repeating-linear-gradient(to bottom, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.22) 2px 3px);
}
[data-fx-vignette="true"] .fx-vig { display: block; background: radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,.6) 100%); }
[data-fx-grain="true"] .fx-grain {
  display: block; inset: -50%; opacity: .07; animation: grain .9s steps(4) infinite;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
@keyframes grain { 25% { transform: translate(-3%, 2%); } 50% { transform: translate(2%, -3%); } 75% { transform: translate(-1%, 3%); } }
[data-fx-glow="subtle"] .stage, [data-fx-glow="subtle"] .stage * { text-shadow: 0 0 5px color-mix(in srgb, currentColor 30%, transparent); }
[data-fx-glow="strong"] .stage, [data-fx-glow="strong"] .stage * { text-shadow: 0 0 3px color-mix(in srgb, currentColor 55%, transparent), 0 0 12px color-mix(in srgb, currentColor 30%, transparent); }
[data-layout-cols80="true"] .stage { max-width: calc(80ch + 4.5em + 54px); font-family: var(--f-system); }

/* ── The ending card ── */
.veil.modal { background: rgba(8,8,10,.62); }
.fake-caret { display: none; }
.form { position: relative; transition: opacity .5s; }
.form.pending { opacity: 0; }
[data-ending-card="terminal"] .signup, [data-ending-card="strip"] .signup { overflow: hidden; }
[data-ending-card="terminal"] .signup {
  border-radius: 8px; background: #0e0e10; border-color: #2c2c32; padding-top: 52px; text-align: left; font-family: var(--f-system);
}
[data-ending-card="terminal"] .signup::before {
  content: "buddy.contra-ethos.com — notify"; position: absolute; top: 0; left: 0; right: 0; height: 30px;
  text-align: center; font: 11px/30px var(--f-system); color: var(--dim); background:
    radial-gradient(circle at 16px 15px, #4a4a50 5px, transparent 5.5px),
    radial-gradient(circle at 34px 15px, #4a4a50 5px, transparent 5.5px),
    radial-gradient(circle at 52px 15px, #4a4a50 5px, transparent 5.5px), #17171a;
  border-bottom: 1px solid #2c2c32;
}
[data-ending-card="terminal"] .headline { font-family: var(--f-system); }
[data-ending-card="terminal"] .form input { border-width: 0 0 1px; border-radius: 0; background: transparent; }
[data-ending-card="strip"] .signup { padding-top: 0; }
[data-ending-card="strip"] .signup::before {
  content: "buddy.contra-ethos.com"; display: block; margin: 0 -28px 22px; padding: 6px 14px; text-align: left;
  font: 11px var(--f-system); color: var(--dim); background: #17171b; border-bottom: 1px solid var(--line);
}
[data-ending-card="strip"] .fake-caret {
  position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: .55em; height: 1.05em;
  background: var(--c-user); animation: blink 1.05s steps(1) infinite;
}
[data-ending-card="strip"] .form:has(input:placeholder-shown) .fake-caret { display: block; }
[data-ending-card="strip"] .form input:placeholder-shown { caret-color: transparent; padding-left: 26px; }

@media (max-width: 560px) {
  [data-user-style="shell"] .msg.user .who, [data-user-style="prompt"] .msg.user .who { display: none; }
  [data-ending-card="strip"] .fake-caret { top: 20px; }
}

/* ── The folder's contents: display styles (ending.fs) ── */
.fs-entry { transition: filter 1.4s ease; }
.fs-list {
  margin: 18px 0 6px calc(4.5em + 14px); font: 13px/1.6 var(--f-system); color: var(--c-system);
  white-space: pre; overflow: hidden;
}
.fs-list .fs-entry { animation: fade .35s ease both; }
.fs-list .fs-name { color: var(--text); }
.fs-list .dir .fs-name { color: #8fb6d9; font-weight: 500; }
.fs-list .fs-meta, .fs-head, .fs-foot { color: var(--faint); }
.fs-foot { margin-top: 6px; }
.fs-ls .fs-entry:nth-child(9) .fs-name { color: #e08a7a; }

/* decrypt: same grid, names glow green while they resolve */
.fs-decrypt .fs-name { color: #9fe0b0; font-variant-ligatures: none; }
.fs-decrypt .fs-item svg { animation: flicker .9s steps(3) both; }
@keyframes flicker { 0%, 40% { opacity: .15; } 60% { opacity: .7; } 80% { opacity: .3; } }

/* access: a bordered panel, reverse-video header, bars that fill row by row, a sweeping scan line */
.fs-access { position: relative; width: min(520px, calc(100% - 4.5em - 14px)); border: 1px solid #3c6b4c; padding: 0 0 8px; color: #9fe0b0; }
.fs-access .fs-head { background: #9fe0b0; color: var(--bg); padding: 2px 10px; margin-bottom: 8px; letter-spacing: .12em; font-weight: 600; animation: blinkhead 1s steps(1) 3 both; }
@keyframes blinkhead { 50% { opacity: 0; } }
.fs-access .fs-entry { display: grid; grid-template-columns: minmax(0, 1fr) 140px 4ch; gap: 12px; align-items: center; padding: 0 10px; animation: fade .2s ease var(--d) both; }
.fs-access .fs-name { color: #c9f0d4; overflow: hidden; text-overflow: ellipsis; }
.fs-access .dir .fs-name { color: #c9f0d4; }
.fs-access .fs-bar { height: 6px; background: linear-gradient(#9fe0b0, #9fe0b0) 0 / 0% 100% no-repeat, #1d3326; animation: fill .7s steps(14) var(--d) forwards; }
@keyframes fill { to { background-size: 100% 100%, auto; } }
.fs-access .fs-pct { text-align: right; opacity: 0; animation: show .1s calc(var(--d) + .7s) forwards; }
@keyframes show { to { opacity: 1; } }
.fs-scan { position: absolute; left: 0; right: 0; height: 30px; top: 0; pointer-events: none;
  background: linear-gradient(to bottom, transparent, rgba(159,224,176,.14), transparent); animation: sweep 1.6s linear 2 both; }
@keyframes sweep { from { top: -30px; } to { top: 100%; opacity: 0; } }
@media (max-width: 560px) {
  .fs-list { margin-left: 0; font-size: 11px; }
  .fs-ls .fs-meta { display: none; }
  .fs-access .fs-entry { grid-template-columns: minmax(0, 1fr) 70px 4ch; }
}

/* ── Turn placement: placed turns scroll on purpose, so no snapping ── */
[data-turn-place="reserve"] .history, [data-turn-place="top"] .history { scroll-snap-type: none; }

/* ── File displays: the folder notice and the folder's contents (files.style) ── */
.msg .fs-display { margin: 6px 0 2px; white-space: normal; }
.msg .fs-grid { grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); margin-left: 0; }
.turn > .fs-rows, .turn > .fs-chips, .turn > .fs-window { margin: 18px 0 6px calc(4.5em + 14px); }
.fs-caption { font: 12px var(--f-system); color: var(--faint); }
.fs-rows, .fs-chips { --fs-ui: "IBM Plex Sans", system-ui, sans-serif; }
.fs-rows svg, .fs-chips svg { fill: none; stroke: currentColor; stroke-width: 3; stroke-linejoin: round; color: var(--c-system); }
.fs-rows svg text, .fs-chips svg text { display: none; }
.fs-rows { display: grid; gap: 1px; max-width: 460px; font: 13.5px/1.5 var(--fs-ui); }
.fs-rows .fs-entry { display: grid; grid-template-columns: 18px minmax(0, 1fr) auto; gap: 10px; align-items: center;
  padding: 5px 10px; border-radius: 6px; animation: fade .3s ease both; }
.fs-rows .fs-entry:nth-child(odd) { background: #141417; }
.fs-rows svg { width: 16px; height: 16px; }
.fs-rows .fs-name { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fs-rows .fs-kind { color: var(--faint); font-size: 12px; }
.fs-chips { display: flex; flex-wrap: wrap; gap: 6px; max-width: 560px; }
.fs-chips .fs-entry { display: inline-flex; align-items: center; gap: 7px; padding: 3px 11px 3px 9px; border: 1px solid var(--line);
  border-radius: 999px; background: #141417; font: 13px/1.5 var(--fs-ui); color: var(--text); animation: fade .3s ease both; }
.fs-chips svg { width: 14px; height: 14px; }
.fs-window { max-width: 520px; border: 1px solid #2c2c32; border-radius: 8px; background: #0f0f12; overflow: hidden; }
.fs-titlebar { height: 26px; font: 11px/26px "IBM Plex Sans", system-ui, sans-serif; color: var(--dim); text-align: center; background:
    radial-gradient(circle at 14px 13px, #4a4a50 4px, transparent 4.5px),
    radial-gradient(circle at 28px 13px, #4a4a50 4px, transparent 4.5px),
    radial-gradient(circle at 42px 13px, #4a4a50 4px, transparent 4.5px), #17171a;
  border-bottom: 1px solid #2c2c32; }
.fs-window .fs-grid { margin: 14px 12px 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.msg .fs-window .fs-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 560px) {
  .turn > .fs-rows, .turn > .fs-chips, .turn > .fs-window { margin-left: 0; }
  .fs-window .fs-grid, .msg .fs-window .fs-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ── Story beats ── */
@keyframes beat-major { from { filter: brightness(1.55) drop-shadow(0 0 6px rgba(255,255,255,.18)); } to { filter: none; } }
@keyframes beat-minor { from { filter: brightness(1.3); } to { filter: none; } }
[data-beat-look="settle"] .msg.beat-major.beat-land .body, [data-beat-look="both"] .msg.beat-major.beat-land .body { animation: beat-major 1.5s ease-out; }
[data-beat-look="settle"] .msg.beat-minor.beat-land .body, [data-beat-look="both"] .msg.beat-minor.beat-land .body { animation: beat-minor 1.1s ease-out; }
[data-beat-look="mark"] .msg.beat-major .body, [data-beat-look="both"] .msg.beat-major .body { position: relative; }
[data-beat-look="mark"] .msg.beat-major .body::before, [data-beat-look="both"] .msg.beat-major .body::before {
  content: ""; position: absolute; left: -9px; top: .45em; bottom: .45em; width: 2px; border-radius: 2px;
  background: currentColor; opacity: .45;
}
