﻿/* HTML Runner — identitas visual COST (cost.biz.id) */

:root {
  --paper: #f0f3f8;
  --band: #e1e9f3;
  --card: #fbfdff;
  --ink: #0e1c2e;
  --ink-soft: #52647c;
  --rule: rgba(14, 28, 46, 0.22);
  --grid-line: rgba(14, 28, 46, 0.09);
  --blue: #1a56b0;
  --on-blue: #ffffff;
  --scope: #0e9cc0;
  --signal: #ffd23f;
  --trace-opacity: 0.45;
}
[data-theme="dark"] {
  --paper: #0e1c2e;
  --band: #14263a;
  --card: #102133;
  --ink: #e8eef7;
  --ink-soft: #9db0c8;
  --rule: rgba(232, 238, 247, 0.18);
  --grid-line: rgba(232, 238, 247, 0.06);
  --blue: #5b8fe0;
  --on-blue: #0e1c2e;
  --scope: #3fc0e0;
  --signal: #ffd23f;
  --trace-opacity: 0.55;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background-color: var(--paper);
  /* grid halus ala COST */
  background-image:
    linear-gradient(var(--grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid-line) 1px, transparent 1px);
  background-size: 32px 32px;
  font-family: "Atkinson Hyperlegible", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
::selection { background: var(--blue); color: var(--on-blue); }

button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }

/* ===== Intro / opening ===== */
.intro {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: var(--paper);
  /* fallback CSS: sembunyikan sendiri walau JS tidak jalan */
  animation: introAutoHide 0.55s cubic-bezier(0.4, 0, 1, 1) 1.7s forwards;
}
.intro-skip .intro { display: none; }
.intro-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 24px;
}
.intro-trace { width: min(70vw, 420px); height: 60px; }
.intro-trace polyline {
  fill: none;
  stroke: var(--blue);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  animation: drawTrace 0.95s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.intro-brand {
  display: flex;
  gap: 10px;
  font: 700 clamp(28px, 6vw, 44px) "Chakra Petch", sans-serif;
  letter-spacing: 0.02em;
  color: var(--ink);
}
.intro-brand span {
  display: inline-block;
  opacity: 0;
  animation: blurIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.intro-brand span:first-child { animation-delay: 0.38s; }
.intro-brand span:last-child { animation-delay: 0.5s; color: var(--blue); }
.intro-tag {
  margin: 0;
  font-size: 13px;
  color: var(--ink-soft);
  opacity: 0;
  animation: blurIn 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.78s both;
}
.intro-bar {
  width: min(56vw, 220px);
  height: 2px;
  border-radius: 2px;
  background: var(--rule);
  overflow: hidden;
}
.intro-bar span {
  display: block;
  height: 100%;
  background: var(--blue);
  transform: scaleX(0);
  transform-origin: left center;
  animation: barFill 1.15s cubic-bezier(0.16, 1, 0.3, 1) 0.25s both;
}

/* ===== Entrance halaman (hanya saat html.anim) ===== */
html.anim .toolbar { animation: slideDown 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.6s both; }
html.anim .brand-name { animation: fadeIn 0.5s ease 0.85s both; }
html.anim .trace polyline { animation: drawTrace 1.1s cubic-bezier(0.16, 1, 0.3, 1) 0.2s both; }
html.anim .editors > .pane { animation: riseScale 0.55s cubic-bezier(0.16, 1, 0.3, 1) 0.85s both; }
html.anim .pane-stack > .pane { animation: riseScale 0.55s cubic-bezier(0.16, 1, 0.3, 1) both; }
html.anim .pane-stack > .pane:nth-child(1) { animation-delay: 0.85s; }
html.anim .pane-stack > .pane:nth-child(2) { animation-delay: 0.94s; }
html.anim .pane-stack > .pane:nth-child(3) { animation-delay: 1.03s; }
html.anim textarea { animation: fadeIn 0.7s ease 1.15s both; }

@keyframes introAutoHide {
  to { opacity: 0; visibility: hidden; transform: scale(1.03); filter: blur(6px); }
}
@keyframes drawTrace {
  from { stroke-dasharray: 2400; stroke-dashoffset: 2400; }
  to { stroke-dasharray: 2400; stroke-dashoffset: 0; }
}
@keyframes riseIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes riseScale {
  from { opacity: 0; transform: translateY(14px) scale(0.985); filter: blur(4px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes blurIn {
  from { opacity: 0; transform: translateY(12px) scale(0.96); filter: blur(8px); }
  to { opacity: 1; transform: translateY(0) scale(1); filter: blur(0); }
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-14px); filter: blur(6px); }
  to { opacity: 1; transform: translateY(0); filter: blur(0); }
}
@keyframes barFill {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--card);
  border-bottom: 1px solid var(--rule);
}
.brand { display: flex; align-items: baseline; gap: 8px; margin-right: auto; }
.brand-name {
  font: 700 17px "Chakra Petch", sans-serif;
  letter-spacing: 0.02em;
}
.brand-tag { font-size: 11px; color: var(--ink-soft); }

.mode-switch {
  display: inline-flex;
  border: 1px solid var(--rule);
  border-radius: 8px;
  overflow: hidden;
  background: var(--paper);
}
.seg {
  padding: 6px 14px;
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font: 600 13px "Chakra Petch", sans-serif;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.seg + .seg { border-left: 1px solid var(--rule); }
.seg.active {
  background: var(--blue);
  color: var(--on-blue);
}
.seg:not(.active):hover { color: var(--ink); }

.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--card);
  color: var(--ink);
  font: 600 13px "Chakra Petch", sans-serif;
  cursor: pointer;
  user-select: none;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}
.btn:hover { border-color: var(--blue); transform: translateY(-1px); }
.btn:active { transform: translateY(1px); }
.btn.primary {
  background: var(--blue);
  border-color: var(--blue);
  color: var(--on-blue);
}
.btn.primary:hover { box-shadow: 0 4px 14px rgba(26, 86, 176, 0.28); }
.btn.small { padding: 2px 8px; font-size: 11px; }

/* ===== Garis trace dekoratif ===== */
.trace {
  display: block;
  width: 100%;
  height: 22px;
  flex: none;
}
.trace polyline {
  fill: none;
  stroke: var(--blue);
  stroke-width: 1.5;
  opacity: var(--trace-opacity);
  vector-effect: non-scaling-stroke;
}

/* ===== Layout: editor satu kolom penuh ===== */
.layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.editors {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.pane-stack {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}
.pane-stack[hidden] { display: none; }
.editors > .pane, .pane-stack > .pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--rule);
}
.pane-stack > .pane:last-child { border-bottom: 0; }
.editors > .pane:last-child { border-bottom: 0; }
.pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--band);
  border-bottom: 1px solid var(--rule);
  font: 700 11px "Chakra Petch", sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  flex: none;
}
textarea {
  flex: 1;
  width: 100%;
  min-height: 0;
  resize: none;
  border: 0;
  outline: none;
  padding: 12px 14px;
  background: var(--card);
  color: var(--ink);
  font: 13px/1.6 ui-monospace, "Cascadia Code", Consolas, Menlo, monospace;
  tab-size: 2;
  caret-color: var(--blue);
}
textarea::placeholder { color: var(--ink-soft); opacity: 0.7; }

/* panel yang baru ditampilkan setelah ganti mode */
.pane-fade { animation: fadeIn 0.28s ease both; }

/* ===== Toast ===== */
.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  max-width: min(90vw, 560px);
  padding: 8px 16px;
  border-radius: 8px;
  background: var(--blue);
  color: var(--on-blue);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 20px rgba(14, 28, 46, 0.25);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  z-index: 10;
  animation: toastIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) both;
}
.toast.hidden { display: none; }
@keyframes toastIn {
  from { opacity: 0; transform: translate(-50%, 10px) scale(0.98); }
  to { opacity: 1; transform: translate(-50%, 0) scale(1); }
}

/* ===== Mobile: semua di atas, switch kecil, tombol gede nyaman ===== */
@media (max-width: 820px) {
  .brand-tag { display: none; }
  .trace { display: none; }
  .toolbar {
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
  }
  .brand { flex: 1 1 auto; }
  .brand-name { font-size: 15px; }
  #btn-theme { padding: 8px 12px; }

  /* switch compact: kecil, gak full-width */
  .mode-switch {
    order: 3;
    flex-basis: 100%;
    width: auto;
    max-width: max-content;
    display: inline-flex;
    justify-self: start;
  }
  .seg { padding: 7px 20px; text-align: center; font-size: 13px; }

  /* tombol gede satu baris rata */
  .actions {
    order: 4;
    flex-basis: 100%;
    display: flex;
    gap: 6px;
  }
  .actions .btn {
    flex: 1 1 0;
    justify-content: center;
    padding: 10px 4px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .actions .btn.primary { flex: 1.5 1 0; }
  .label-ext { display: none; }
  .intro-trace { height: 44px; }
}

/* ===== Reduced motion: waive semua animasi ===== */
@media (prefers-reduced-motion: reduce) {
  .intro { display: none; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
