@tailwind base;
@tailwind components;
@tailwind utilities;

/* ─── Palette tokens (dark default) ─── */
:root {
  --base: #000000;
  --mantle: #0c0a09;
  --surface0: #1c1917;
  --surface1: #292524;
  --surface2: #44403c;
  --overlay1: #78716c;
  --subtext0: #a8a29e;
  --subtext1: #d6d3d1;
  --text: #e7e5e4;

  --mauve: #a78cc4;
  --lavender: #9faece;
  --sky: #7da2b5;
  --green: #8ea98c;
  --yellow: #c7b07a;

  /* Semantic */
  --bg: var(--base);
  --border: var(--surface1);
  --fg: var(--text);
  --fg-muted: var(--subtext0);
  --fg-subtle: var(--overlay1);
  --accent: var(--lavender);
  --accent-warm: var(--yellow);
  --kst-purple: #c86bff;
  --grid-color: rgba(255, 255, 255, 0.07);
  --grid-size: 96px;
}

/* ─── Light palette (shared by media query + explicit override) ─── */
@media (prefers-color-scheme: light) {
  :root {
    --base: #e8e4df;
    --mantle: #dedad4;
    --surface0: #cbc6bf;
    --surface1: #b8b3ac;
    --surface2: #a09b94;
    --overlay1: #7a7470;
    --subtext0: #5e5955;
    --subtext1: #47433f;
    --text: #302d2a;

    --mauve: #7c3aed;
    --lavender: #5b6fd6;
    --sky: #0284c7;
    --green: #16a34a;
    --yellow: #b45309;

    --kst-purple: #7c3aed;
    --grid-color: rgba(0, 0, 0, 0.07);
  }
}

/* ─── Explicit theme overrides (beat media query via specificity) ─── */
html[data-theme="light"] {
  --base: #eff1f5;
  --mantle: #e6e9ef;
  --surface0: #ccd0da;
  --surface1: #bcc0cc;
  --surface2: #acb0be;
  --overlay1: #8c8fa1;
  --subtext0: #6c6f85;
  --subtext1: #5c5f77;
  --text: #4c4f69;

  --mauve: #8839ef;
  --lavender: #7287fd;
  --sky: #04a5e5;
  --green: #40a02b;
  --yellow: #df8e1d;

  --kst-purple: #8839ef;
  --grid-color: rgba(0, 0, 0, 0.055);
}

html[data-theme="dark"] {
  --base: #000000;
  --mantle: #0c0a09;
  --surface0: #1c1917;
  --surface1: #292524;
  --surface2: #44403c;
  --overlay1: #78716c;
  --subtext0: #a8a29e;
  --subtext1: #d6d3d1;
  --text: #e7e5e4;

  --mauve: #a78cc4;
  --lavender: #9faece;
  --sky: #7da2b5;
  --green: #8ea98c;
  --yellow: #c7b07a;

  --kst-purple: #c86bff;
  --grid-color: rgba(255, 255, 255, 0.07);
}

/* ─── Reset ─── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  background: var(--bg);
  color: var(--fg);
  font-family: "JetBrains Mono", "Courier New", Courier, monospace;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--grid-color) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-color) 1px, transparent 1px);
  background-size: var(--grid-size) var(--grid-size);
  background-position: -1px -1px;
  background-attachment: fixed;
  min-height: 100vh;
}

a {
  color: inherit;
  text-decoration: none;
}
button {
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
  font: inherit;
}

/* ─── Layout ─── */
.page-wrap {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 32px;
}

/* ─── Logo banner ─── */
.logo-wrap {
  margin-top: 40px;
  margin-bottom: 40px;
  display: flex;
  justify-content: center;
}

.logo-img {
  width: 100%;
  max-width: 820px;
  display: block;
}

/* ─── Sections ─── */
.section {
  padding: 0 0 56px;
}

.section-label {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.22em;
  color: var(--mauve);
  margin-bottom: 14px;
}

/* ─── Grid box — bordered container ─── */
.grid-box {
  border: 1px solid var(--border);
  width: 100%;
  background: var(--bg);
}

/* ─── Hero ─── */
.hero-row {
  padding: 72px 32px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.hero-tagline {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--fg);
  line-height: 1.4;
}

.hero-etymology {
  margin-top: 6px;
  font-size: 13px;
  color: var(--fg-subtle);
  letter-spacing: 0.02em;
}

.hero-etymology-jp {
  color: var(--fg);
}

.hero-sub {
  font-size: 16px;
  letter-spacing: 0.22em;
  color: var(--fg-subtle);
  margin-top: 14px;
}

/* ─── Action rows ─── */
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
}

.action-label {
  display: inline-flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  flex-shrink: 0;
  white-space: nowrap;
}

.accent-warm {
  color: var(--accent-warm);
}

.version-badge {
  margin-left: 10px;
}

.star-count {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 10px;
}

.action-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.action-cmd {
  font-family: inherit;
  font-size: 16px;
  color: var(--fg);
  letter-spacing: 0.02em;
}

/* Install pill — terminal-style command box */
.install-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: var(--mantle);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  max-width: 100%;
  overflow: hidden;
}

.install-pill-prompt {
  color: var(--kst-purple);
  font-weight: 600;
  user-select: none;
  flex-shrink: 0;
}

.install-pill-cmd {
  font-family: inherit;
  color: var(--fg);
  letter-spacing: 0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.install-pill .copy-btn {
  border: none;
  padding: 2px 4px;
  margin-left: 4px;
}

.action-link {
  font-size: 16px;
  color: var(--accent);
  letter-spacing: 0.04em;
  transition: color 0.12s;
}

.action-link:hover {
  color: var(--fg);
}

.arrow {
  color: var(--fg-subtle);
}

/* ─── Copy button ─── */
.copy-btn {
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 0.08em;
  color: var(--fg-subtle);
  border: 1px solid var(--border);
  padding: 3px 8px;
  transition:
    color 0.12s,
    border-color 0.12s;
  flex-shrink: 0;
}

.copy-btn:hover {
  color: var(--fg);
  border-color: var(--fg-subtle);
}
.copy-btn.copied {
  color: var(--green);
  border-color: var(--green);
}

/* ─── Agents ─── */
.agents-header {
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border);
}

.agents-cells {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
}

.agent-cell {
  padding: 18px 24px;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: 0.14em;
  color: var(--fg-muted);
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
  text-align: center;
  transition:
    color 0.12s,
    background 0.12s;
}

.agent-cell:nth-child(4n + 1) {
  border-left: none;
}
.agent-cell:hover {
  color: var(--fg);
  background: var(--surface0);
}

.show-more-row {
  width: 100%;
  padding: 16px 24px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  color: var(--fg-subtle);
  border-top: 1px solid var(--border);
  text-align: center;
  transition:
    color 0.12s,
    background 0.12s;
}

.show-more-row:hover {
  color: var(--fg);
  background: var(--surface0);
}

/* ─── Features grid ─── */
.feat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
}

.feat-cell {
  padding: 28px 24px;
  border-top: 1px solid var(--border);
  border-left: 1px solid var(--border);
}

.feat-cell:nth-child(-n + 3) {
  border-top: none;
}
.feat-cell:nth-child(3n + 1) {
  border-left: none;
}

.feat-cell-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--accent);
  margin-bottom: 10px;
}

.feat-cell-desc {
  font-size: 15px;
  color: var(--fg-muted);
  line-height: 1.7;
  letter-spacing: 0.02em;
}

.feat-code-block {
  border: 1px solid var(--border);
  overflow-x: auto;
  background: var(--bg);
}

.feat-code-header {
  padding: 9px 16px;
  font-size: 16px;
  letter-spacing: 0.16em;
  color: var(--fg-subtle);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

.feat-code-body {
  padding: 18px 20px;
  font-size: 16px;
  line-height: 1.9;
  letter-spacing: 0.02em;
  background: var(--bg);
  white-space: pre;
}

/* Syntax lines */
.sy-line {
  display: flex;
  gap: 20px;
}

.sy-ln {
  color: var(--fg-subtle);
  user-select: none;
  text-align: right;
  min-width: 2ch;
  flex-shrink: 0;
  opacity: 0.4;
}

.sy-line-content {
  flex: 1;
}

/* Syntax */
.sy-key {
  color: var(--lavender);
}
.sy-str {
  color: var(--sky);
}
.sy-url {
  color: var(--mauve);
}
.sy-cmt {
  color: var(--fg-subtle);
}
.sy-dash {
  color: var(--fg-subtle);
}
.sy-punct {
  color: var(--fg-muted);
}

/* ─── Install ─── */
.install-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px;
  border-top: 1px solid var(--border);
}

.install-row:first-child {
  border-top: none;
}

.install-label {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--fg-subtle);
  flex-shrink: 0;
  min-width: 210px;
}

.install-right {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}

.install-cmd {
  font-family: inherit;
  font-size: 15px;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.02em;
}

/* ─── Footer ─── */
.footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 40px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  background: var(--bg);
}

.footer-left {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 15px;
  letter-spacing: 0.1em;
  color: var(--fg-subtle);
}

.footer-logo {
  font-weight: 700;
  letter-spacing: 0.14em;
}
.footer-sep {
  opacity: 0.3;
}

.footer-links {
  display: flex;
  gap: 24px;
}

.footer-link {
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--fg-subtle);
  transition: color 0.12s;
}

.footer-link:hover {
  color: var(--fg);
}

.footer-icon {
  font-size: 18px;
  color: var(--fg-subtle);
  transition: color 0.12s;
  display: flex;
  align-items: center;
}

.footer-icon:hover {
  color: var(--fg);
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .page-wrap {
    padding: 0 20px;
  }

  .action-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .agents-cells {
    grid-template-columns: repeat(2, 1fr);
  }
  .agent-cell:nth-child(4n + 1) {
    border-left: 1px solid var(--border);
  }
  .agent-cell:nth-child(2n + 1) {
    border-left: none;
  }

  .feat-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .feat-cell:nth-child(-n + 3) {
    border-top: 1px solid var(--border);
  }
  .feat-cell:nth-child(-n + 2) {
    border-top: none;
  }
  .feat-cell:nth-child(3n + 1) {
    border-left: 1px solid var(--border);
  }
  .feat-cell:nth-child(2n + 1) {
    border-left: none;
  }

  .install-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }
  .install-label {
    min-width: unset;
  }
  .install-cmd {
    white-space: normal;
    word-break: break-all;
  }

  .footer {
    flex-direction: column;
    gap: 20px;
    text-align: center;
  }
  .footer-left {
    flex-wrap: wrap;
    justify-content: center;
  }
}

@media (max-width: 480px) {
  .hero-row {
    padding: 48px 20px;
  }
  .hero-tagline {
    font-size: 16px;
  }
  .agents-cells {
    grid-template-columns: 1fr 1fr;
  }
  .feat-grid {
    grid-template-columns: 1fr;
  }
  .feat-cell {
    border-left: none !important;
    border-top: 1px solid var(--border) !important;
  }
  .feat-cell:first-child {
    border-top: none !important;
  }
}
