/* src/style.css */
:root {
  color: #171815;
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light dark;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --ink: #171815;
  --paper: #e9e7dd;
  --acid: #d8ff52;
  --muted: #6b6b63;
  --line: #1718153d;
  --grid-row: #17181509;
  --grid-column: #17181506;
  --panel: #f4f2eac2;
  --panel-soft: #f4f2eab3;
  --shadow: var(--ink);
  --focus-inset: #17181547;
  --placeholder: #9b9a91;
  --output: #171815;
  --output-ink: #efeee6;
  --output-muted: #9c9d93;
  --output-empty: #77786f;
  --output-line: #fff3;
  --output-glow: #d8ff5214;
  --output-hover: #efeee6;
  --output-hover-ink: #171815;
  --acid-hover: #efffb4;
  --on-acid: #171815;
  --selected: var(--ink);
  --selected-ink: var(--acid);
  background: #e9e7dd;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --buncss-light: ;
    --buncss-dark: initial;
    color: #efeee6;
    --ink: #efeee6;
    --paper: #121310;
    --acid: #cffa4c;
    --muted: #a2a39a;
    --line: #efeee63b;
    --grid-row: #efeee60a;
    --grid-column: #efeee608;
    --panel: #1d1e1ad1;
    --panel-soft: #1d1e1ac2;
    --shadow: #050604;
    --focus-inset: #efeee64d;
    --placeholder: #8e8f86;
    --output: #090a08;
    --output-glow: #cffa4c1c;
    --acid-hover: #e7ffa0;
    --selected: var(--acid);
    --selected-ink: var(--on-acid);
    background: #121310;
  }
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  min-width: 320px;
  min-height: 100%;
}

body {
  background: linear-gradient(var(--grid-row) 1px, transparent 1px), linear-gradient(90deg, var(--grid-column) 1px, transparent 1px), var(--paper);
  background-size: 100% 48px, 48px 100%, auto;
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
}

button, textarea, input {
  font: inherit;
}

button {
  color: inherit;
}

button:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

input:focus-visible {
  outline: 3px solid var(--acid);
  outline-offset: 3px;
}

textarea:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px var(--focus-inset);
}

.page-shell {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 32px clamp(20px, 4vw, 64px) 28px;
}

.hero {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto 1fr;
  border-top: 1px solid var(--ink);
  row-gap: clamp(20px, 3vw, 38px);
  min-height: 220px;
  padding: 22px 0 30px;
}

.hero__index {
  grid-column: 1 / -1;
  grid-row: 1;
  letter-spacing: .14em;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.hero__content {
  grid-column: 1;
  grid-row: 2;
  align-self:  end;
}

.hero h1 {
  letter-spacing: -.08em;
  margin: 0;
  font-family: ui-serif, Noto Serif SC, Songti SC, serif;
  font-size: clamp(58px, 9vw, 132px);
  font-weight: 800;
  line-height: .88;
}

.hero p {
  color: var(--muted);
  letter-spacing: .08em;
  max-width: 560px;
  margin: 25px 0 0 6px;
  font-family: ui-serif, Noto Serif SC, Songti SC, serif;
  font-size: clamp(16px, 2vw, 22px);
}

.hero__mark {
  grid-column: 2;
  grid-row: 2;
  align-self:  end;
  padding-bottom: 2px;
  font-size: clamp(64px, 9vw, 124px);
  font-weight: 300;
  line-height: .8;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  border: 1px solid var(--ink);
  box-shadow: 9px 9px 0 var(--shadow);
}

.panel {
  min-height: 460px;
}

.panel--input {
  display: flex;
  background: var(--panel);
  flex-direction: column;
}

.panel--output {
  display: flex;
  background: radial-gradient(circle at 15% 18%, var(--output-glow), transparent 25%), var(--output);
  color: var(--output-ink);
  border-left: 1px solid var(--ink);
  flex-direction: column;
}

.panel__heading {
  display: flex;
  border-bottom: 1px solid var(--line);
  justify-content: space-between;
  align-items:  center;
  min-height: 76px;
  padding: 18px 22px;
}

.panel__heading > div {
  display: flex;
  align-items: baseline;
  gap: 12px;
}

.panel__heading--dark {
  border-color: var(--output-line);
}

.panel__heading h2, .keyword-stage h2, .control-deck h2 {
  letter-spacing: .06em;
  margin: 0;
  font-size: 19px;
  font-weight: 650;
}

.panel__number {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.panel--output .panel__number {
  color: var(--output-muted);
}

.counter {
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11px;
}

.panel--output .counter {
  color: var(--output-muted);
}

textarea {
  resize: none;
  color: var(--ink);
  letter-spacing: .04em;
  background: none;
  border: 0;
  flex: 1;
  width: 100%;
  min-height: 340px;
  padding: 28px 30px 34px;
  font-family: ui-serif, Noto Serif SC, Songti SC, serif;
  font-size: clamp(20px, 2.1vw, 28px);
  line-height: 1.85;
}

textarea::placeholder {
  color: var(--placeholder);
}

.mosaic-output {
  overflow-wrap: anywhere;
  letter-spacing: .09em;
  white-space: pre-wrap;
  flex: 1;
  min-height: 316px;
  padding: 30px;
  font-family: Noto Serif SC, Songti SC, ui-serif, Courier New, serif;
  font-size: clamp(21px, 2.25vw, 31px);
  line-height: 1.75;
}

.mosaic-output--empty {
  color: var(--output-empty);
}

.output-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border-top: 1px solid var(--output-line);
}

.button {
  cursor: pointer;
  letter-spacing: .06em;
  border: 0;
  min-height: 64px;
  padding: 12px 20px;
  transition: color .16s, background .16s;
  font-weight: 700;
}

.button--light {
  background: var(--acid);
  color: var(--on-acid);
}

.button--light:hover {
  background: var(--acid-hover);
}

.button--outline {
  color: var(--output-ink);
  border-left: 1px solid var(--output-line);
  background: none;
}

.button--outline:hover {
  color: var(--output-hover-ink);
  background: var(--output-hover);
}

.control-deck {
  display: grid;
  grid-template-columns: minmax(160px, .7fr) 2fr;
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  gap: 40px;
  margin-top: 76px;
  padding: 26px 0 38px;
}

.control-deck__title > span {
  display: block;
  color: var(--muted);
  letter-spacing: .13em;
  margin-bottom: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 10px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 34px;
}

.control {
  display: block;
}

.control__heading {
  display: flex;
  justify-content: space-between;
  font-weight: 720;
}

.control__heading output {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  font-weight: 500;
}

.control__hint {
  display: block;
  color: var(--muted);
  min-height: 36px;
  margin-top: 7px;
  font-size: 12px;
  line-height: 1.5;
}

input[type="range"] {
  cursor: pointer;
  appearance: none;
  background: none;
  width: 100%;
  height: 18px;
  margin-top: 18px;
}

input[type="range"]::-webkit-slider-runnable-track {
  background: var(--ink);
  height: 2px;
}

input[type="range"]::-moz-range-track {
  background: var(--ink);
  height: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  background: var(--acid);
  border: 2px solid var(--ink);
  border-radius: 0;
  width: 18px;
  height: 18px;
  margin-top: -8px;
}

input[type="range"]::-moz-range-thumb {
  background: var(--acid);
  border: 2px solid var(--ink);
  border-radius: 0;
  width: 16px;
  height: 16px;
}

.keyword-stage {
  margin-top: 74px;
}

.keyword-stage__heading {
  display: flex;
  justify-content: space-between;
  align-items:  end;
  gap: 24px;
}

.keyword-stage__heading > div {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: baseline;
  gap: 0 12px;
}

.keyword-stage__heading p {
  grid-column: 2;
  color: var(--muted);
  margin: 9px 0 0;
  font-size: 13px;
}

.text-button {
  cursor: pointer;
  border: 0;
  border-bottom: 1px solid var(--ink);
  background: none;
  padding: 8px 0;
  font-size: 13px;
  font-weight: 650;
}

.text-button:hover {
  border-bottom-width: 3px;
}

.keyword-list {
  display: flex;
  background: var(--panel-soft);
  border: 1px solid var(--ink);
  flex-wrap: wrap;
  gap: 9px;
  min-height: 110px;
  margin-top: 24px;
  padding: 24px;
}

.keyword-token {
  cursor: pointer;
  border: 1px solid var(--line);
  background: none;
  min-width: 46px;
  padding: 9px 13px;
  transition: transform .12s, color .12s, background .12s;
  font-family: ui-serif, Noto Serif SC, Songti SC, serif;
  font-size: 15px;
}

.keyword-token:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
}

.keyword-token--selected {
  color: var(--selected-ink);
  background: var(--selected);
  border-color: var(--selected);
}

.keyword-list__empty {
  color: var(--muted);
  margin: auto;
  font-size: 13px;
}

footer {
  display: flex;
  color: var(--muted);
  border-top: 1px solid var(--line);
  letter-spacing: .08em;
  justify-content: space-between;
  gap: 24px;
  margin-top: 96px;
  padding-top: 18px;
  font-size: 11px;
}

footer p {
  margin: 0;
}

.toast {
  position: fixed;
  z-index: 10;
  color: var(--on-acid);
  background: var(--acid);
  border: 1px solid var(--ink);
  box-shadow: 5px 5px 0 var(--shadow);
  opacity: 0;
  pointer-events: none;
  padding: 13px 18px;
  transition: opacity .18s, transform .18s;
  font-size: 13px;
  font-weight: 700;
  bottom: 24px;
  right: 24px;
  transform: translateY(18px);
}

.toast--visible {
  opacity: 1;
  transform: translateY(0);
}

.sr-only {
  position: absolute;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
}

@media (max-width: 860px) {
  .page-shell {
    padding-top: 20px;
  }

  .hero {
    min-height: 190px;
  }

  .hero__mark {
    display: none;
  }

  .workspace {
    grid-template-columns: 1fr;
    box-shadow: 6px 6px 0 var(--shadow);
  }

  .panel {
    min-height: 400px;
  }

  .panel--output {
    border-top: 1px solid var(--ink);
    border-left: 0;
  }

  .control-deck {
    grid-template-columns: 1fr;
    gap: 30px;
    margin-top: 64px;
  }
}

@media (max-width: 640px) {
  .page-shell {
    padding-inline-start: 14px;
    padding-inline-end: 14px;
  }

  .hero {
    min-height: 164px;
    padding-bottom: 22px;
  }

  .hero h1 {
    font-size: clamp(52px, 17vw, 78px);
  }

  .hero p {
    margin-top: 18px;
    font-size: 14px;
  }

  .panel {
    min-height: 360px;
  }

  .panel__heading {
    min-height: 66px;
    padding: 15px 17px;
  }

  textarea, .mosaic-output {
    min-height: 290px;
    padding: 22px 18px;
    font-size: 20px;
  }

  .controls {
    grid-template-columns: 1fr;
    gap: 30px;
  }

  .control__hint {
    min-height: auto;
  }

  .keyword-stage {
    margin-top: 58px;
  }

  .keyword-stage__heading {
    align-items:  start;
  }

  .keyword-stage__heading p {
    grid-column: 1 / -1;
  }

  .keyword-list {
    padding: 16px;
  }

  footer {
    flex-direction: column;
    margin-top: 70px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *:before, *:after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
  }
}
