/*! hitung.id — global.css v1.0.4 (Tahap 1, revisi lebar HP + baris chip)
 *  Lokasi: https://hitung.id/css/global.css
 *  Template desain bersama untuk SEMUA kalkulator rumus.
 *  Semua class berawalan .hc- agar tidak bentrok dengan tema WordPress.
 *  Breakpoint: HP <= 699px (1 kolom, hasil sticky) | Tablet/Desktop >= 700px (2 kolom)
 */

/* ========== 1. TOKEN DESAIN ========== */
:root {
  --hc-navy: #0b2a5b;
  --hc-navy-deep: #081f45;
  --hc-sky: #9dd6f2;
  --hc-sky-soft: #e8f4fc;
  --hc-ink: #0b2a5b;          /* warna teks/border utama (navy) */
  --hc-bg: #f4f8fc;           /* latar area kalkulator */
  --hc-surface: #ffffff;      /* latar kartu/panel */
  --hc-line: #d3dfec;
  --hc-muted: #51627a;
  --hc-pink: #ffd9e2;         /* latar hasil saat error */
  --hc-err: #9b1239;
  --hc-ok: #13795b;
  --hc-focus: #1d6fe0;
  --hc-radius: 16px;
  --hc-radius-sm: 12px;
  --hc-shadow: 0 1px 2px rgba(11, 42, 91, .08), 0 6px 18px rgba(11, 42, 91, .07);
  --hc-gap: 16px;
  --hc-sticky-top: 0px;       /* diisi core.js sesuai tinggi header tema */
  --hc-result-bg: var(--hc-navy);
  --hc-result-fg: #ffffff;
}

:root[data-hc-theme="dark"] {
  --hc-ink: #cfe3ff;
  --hc-bg: #0d1626;
  --hc-surface: #14213a;
  --hc-line: #2b3e5e;
  --hc-muted: #a3b4cc;
  --hc-sky: #1f4f86;
  --hc-sky-soft: #172c4b;
  --hc-pink: #5a1d33;
  --hc-err: #ffc2d1;
  --hc-ok: #6fe0bb;
  --hc-focus: #7db6ff;
  --hc-result-bg: #0a1d44;
  --hc-result-fg: #ffffff;
  --hc-shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 6px 18px rgba(0, 0, 0, .35);
}

/* ========== 2. KONTAINER & LAYOUT ========== */
.hc-app,
.hc-app *,
.hc-modal,
.hc-modal * { box-sizing: border-box; }

.hc-app {
  display: flex;                 /* HP: 1 kolom (flex agar position:sticky bekerja) */
  flex-direction: column;
  gap: var(--hc-gap);
  width: 100%;
  max-width: 1080px;
  margin: 1.25rem auto;
  padding: clamp(12px, 3vw, 24px);
  background: var(--hc-bg);
  color: var(--hc-ink);
  border-radius: 20px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.5;
  position: relative;
}

.hc-app.hc-loading { min-height: 0; }
.hc-app.hc-loading::before {
  content: "Memuat kalkulator…";
  display: block;
  padding: 28px 12px;
  text-align: center;
  color: var(--hc-muted);
  background: var(--hc-surface);
  border-radius: var(--hc-radius);
}
.hc-app.hc-loading .hc-desc { display: none; }
.hc-app.hc-failed::before { content: "Kalkulator tidak dapat dimuat. Muat ulang halaman."; }

/* Urutan HP (sesuai ketentuan): pilihan → hasil (sticky) → input → keterangan → deskripsi */
.hc-top   { order: 0; }
.hc-pilih { order: 1; }
.hc-hasil { order: 2; }
.hc-input { order: 3; }
.hc-ket   { order: 4; }
.hc-desc  { order: 5; }

@media (min-width: 700px) {
  .hc-app {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.08fr);
    grid-template-areas:
      "top   top"
      "pilih pilih"
      "input hasil"
      "input ket"
      "desc  desc";
    grid-template-rows: auto auto auto 1fr auto;
    column-gap: clamp(16px, 2.6vw, 28px);
    row-gap: var(--hc-gap);
    align-items: start;
  }
  .hc-top   { grid-area: top; }
  .hc-pilih { grid-area: pilih; }
  .hc-input { grid-area: input; }
  .hc-hasil { grid-area: hasil; }
  .hc-ket   { grid-area: ket; }
  .hc-desc  { grid-area: desc; }
}

.hc-card {
  background: var(--hc-surface);
  border: 1px solid var(--hc-line);
  border-radius: var(--hc-radius);
  box-shadow: var(--hc-shadow);
  padding: clamp(14px, 2.4vw, 22px);
}

.hc-h {
  margin: 0 0 .75rem;
  font-size: 1.05rem;
  line-height: 1.3;
  font-weight: 700;
  color: var(--hc-ink);
}

/* ========== 3. BARIS ATAS: PERSAMAAN & PERKAKAS ========== */
.hc-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.hc-eq {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex-wrap: wrap;
}
.hc-eq-label {
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--hc-muted);
}
.hc-eq-math { font-size: 1.35rem; color: var(--hc-ink); }
.hc-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hc-tool-label { font-size: .85rem; color: var(--hc-muted); display: inline-flex; align-items: center; gap: 6px; }

math { font-family: "Latin Modern Math", "STIX Two Math", "Cambria Math", "Noto Sans Math", serif; font-size: 1.1em; }

/* ========== 4. TOMBOL UMUM ========== */
.hc-btn,
.hc-select {
  font: inherit;
  font-size: .9rem;
  color: var(--hc-ink);
  background: var(--hc-surface);
  border: 1px solid var(--hc-line);
  border-radius: 10px;
  min-height: 40px;
  padding: 6px 12px;
  cursor: pointer;
  line-height: 1.2;
}
.hc-btn:hover,
.hc-select:hover { border-color: var(--hc-ink); }
.hc-btn[disabled] { opacity: .45; cursor: not-allowed; }
.hc-app :focus-visible,
.hc-modal :focus-visible,
.hc-fab:focus-visible {
  outline: 3px solid var(--hc-focus);
  outline-offset: 2px;
}

/* ========== 5. AREA PILIHAN VARIABEL (#Pilihan_Hitung) ========== */
.hc-pilih-label {
  margin: 0 0 8px;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--hc-muted);
}
.hc-chips { display: flex; flex-wrap: wrap; gap: 10px; align-items: stretch; }
/* Grup radio dibuat 'transparan' agar tombol Penjelasan dan tombol hitung (a, b, c)
   menjadi anggota SATU baris flex yang sama: sejajar, baru turun ke baris berikut jika tidak muat. */
.hc-chip-group { display: contents; }

.hc-chip {
  font: inherit;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  color: var(--hc-ink);                       /* teks navy */
  background: var(--hc-surface);              /* tidak terpilih: putih/netral */
  border: 2px dashed var(--hc-ink);           /* tidak terpilih: dashed navy */
  line-height: 1.15;
  transition: background-color .15s ease, transform .1s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.hc-chip:hover { background: var(--hc-sky-soft); }
.hc-chip:active { transform: scale(.97); }
.hc-chip b { font-size: 1.05rem; font-weight: 700; }
.hc-chip small { font-size: .8rem; opacity: .85; }

.hc-chip[aria-checked="true"] {               /* terpilih: solid + biru langit + penanda */
  border-style: solid;
  background: var(--hc-sky);
  font-weight: 700;
}
.hc-chip[aria-checked="true"]::before {
  content: "";
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  border-radius: 50%;
  background: var(--hc-ink)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4 8.4l2.6 2.6L12 5.6' fill='none' stroke='%23fff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
    center / 100% no-repeat;
}
:root[data-hc-theme="dark"] .hc-chip[aria-checked="true"] { color: #fff; }

.hc-chip-info { font-weight: 600; }          /* tombol Penjelasan: gaya sama dgn tidak terpilih */
.hc-chip-info svg { width: 18px; height: 18px; flex: 0 0 18px; }

/* ========== 6. AREA INPUT (#Input_Variabel) ========== */
.hc-input-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: .6rem; }
.hc-input-head .hc-h { margin: 0; }
.hc-fields { display: flex; flex-direction: column; gap: 14px; }
.hc-field { display: flex; flex-direction: column; align-items: stretch; text-align: left; }
.hc-field label {
  display: block;
  margin: 0 0 6px;
  text-align: left;
  font-size: .95rem;
  font-weight: 600;
  color: var(--hc-ink);
}
.hc-field label b { font-size: 1.05rem; margin-right: 4px; }
.hc-field label span { font-weight: 500; color: var(--hc-muted); }
.hc-inwrap { position: relative; display: flex; align-items: stretch; width: 100%; }
.hc-inwrap input {
  width: 100%;
  min-height: 50px;
  margin: 0;
  padding: 10px 14px;
  font: inherit;
  font-size: 1.125rem;                        /* >=16px: cegah zoom otomatis iOS */
  text-align: left;
  color: var(--hc-ink);
  background: var(--hc-surface);
  border: 2px solid var(--hc-line);
  border-radius: var(--hc-radius-sm);
  -webkit-appearance: none;
  appearance: none;
}
.hc-inwrap input::placeholder { color: var(--hc-muted); opacity: .6; }
.hc-inwrap input:hover { border-color: var(--hc-ink); }
.hc-inwrap input:focus { outline: none; border-color: var(--hc-focus); box-shadow: 0 0 0 3px rgba(29, 111, 224, .25); }
.hc-field.is-invalid input { border-color: var(--hc-err); background: var(--hc-pink); }
:root[data-hc-theme="dark"] .hc-field.is-invalid input { color: #fff; }
.hc-has-sign input { padding-right: 62px; }
.hc-sign {
  position: absolute;
  top: 5px;
  right: 5px;
  bottom: 5px;
  width: 48px;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--hc-ink);
  background: var(--hc-sky-soft);
  border: 1px solid var(--hc-line);
  border-radius: 9px;
  cursor: pointer;
  touch-action: manipulation;
}
.hc-field-err { min-height: 0; margin-top: 4px; font-size: .85rem; color: var(--hc-err); text-align: left; }
.hc-field-err:empty { display: none; }

/* ========== 7. AREA HASIL (#Hasil_Hitung) ========== */
.hc-hasil {
  background: var(--hc-result-bg);
  color: var(--hc-result-fg);
  border-radius: var(--hc-radius);
  box-shadow: var(--hc-shadow);
  padding: clamp(16px, 3vw, 26px);
  text-align: center;
  position: relative;
  min-height: 120px;
  transition: background-color .2s ease, opacity .2s ease, transform .2s ease;
}
.hc-hasil-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.hc-hasil-title { font-size: .78rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; opacity: .8; }
.hc-copy {
  font: inherit;
  font-size: .85rem;
  color: inherit;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 999px;
  min-height: 36px;
  padding: 4px 14px;
  cursor: pointer;
  touch-action: manipulation;
}
.hc-copy:hover { background: rgba(255, 255, 255, .26); }
.hc-copy[disabled] { opacity: .4; cursor: not-allowed; }
.hc-hasil :focus-visible { outline-color: #fff; }

.hc-outs { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px 28px; }
.hc-out { flex: 1 1 140px; min-width: 0; }
.hc-out-name { display: block; font-size: .95rem; font-weight: 600; opacity: .92; }
.hc-out-name small { font-weight: 400; opacity: .85; margin-left: 4px; }
.hc-out-val {
  display: block;
  min-height: 1.2em;
  margin-top: 2px;
  font-size: clamp(2rem, 6.5vw, 3.25rem);
  line-height: 1.15;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.hc-hasil[data-state="pending"] .hc-out-val { opacity: .55; }

/* Error: nilai kosong + latar merah muda */
.hc-hasil[data-state="error"] { background: var(--hc-pink); color: var(--hc-err); }
.hc-hasil[data-state="error"] .hc-out-val { visibility: hidden; }
.hc-hasil[data-state="error"] .hc-copy { visibility: hidden; }
.hc-hasil-hint { display: none; margin: 4px 0 0; font-size: .85rem; font-weight: 600; }

/* ========== 8. AREA KETERANGAN (#Keterangan_Hitung) ========== */
.hc-ket .hc-h { margin-bottom: .5rem; }
.hc-ket-body > * { margin: 0 0 .6rem; }
.hc-ket-body > *:last-child { margin-bottom: 0; }
.hc-ket-rumus { font-size: 1.2rem; padding: 8px 12px; background: var(--hc-sky-soft); border-radius: 10px; overflow-x: auto; }
.hc-ket .hc-msg-err {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--hc-err);
  background: var(--hc-pink);
  font-weight: 600;
}
.hc-ket .hc-msg-err::before { content: "⚠"; }
.hc-ket .hc-msg-info { color: var(--hc-muted); }
.hc-ket .hc-msg-ok { color: var(--hc-ok); font-weight: 600; }

/* ========== 9. AREA DESKRIPSI (#Deskripsi_Rumus) ========== */
.hc-desc {
  background: var(--hc-surface);
  color: var(--hc-ink);
  border: 1px solid var(--hc-line);
  border-radius: var(--hc-radius);
  padding: clamp(16px, 3vw, 28px);
  scroll-margin-top: calc(var(--hc-sticky-top) + 12px);
  line-height: 1.75;
}
.hc-desc:focus { outline: none; }
.hc-desc h2 { margin: 1.6em 0 .5em; font-size: 1.35rem; line-height: 1.3; color: var(--hc-ink); }
.hc-desc h2:first-child { margin-top: 0; }
.hc-desc h3 { margin: 1.3em 0 .4em; font-size: 1.1rem; color: var(--hc-ink); }
.hc-desc p, .hc-desc ul, .hc-desc ol { margin: 0 0 1em; }
.hc-desc li { margin-bottom: .35em; }
.hc-desc a { color: var(--hc-focus); }
.hc-desc .hc-formula {
  display: block;
  margin: 1em 0;
  padding: 12px 16px;
  text-align: center;
  font-size: 1.3rem;
  background: var(--hc-sky-soft);
  border-left: 4px solid var(--hc-ink);
  border-radius: 8px;
  overflow-x: auto;
}
.hc-desc .hc-callout {
  margin: 1em 0;
  padding: 12px 16px;
  background: var(--hc-sky-soft);
  border-radius: 10px;
}
.hc-desc .hc-callout h3:first-child { margin-top: 0; }
.hc-desc .hc-callout ol { margin-bottom: .6em; }
.hc-desc .hc-tablewrap { overflow-x: auto; margin: 0 0 1em; }
.hc-desc table { width: 100%; border-collapse: collapse; font-size: .95rem; }
.hc-desc th, .hc-desc td { padding: 8px 10px; text-align: left; border: 1px solid var(--hc-line); vertical-align: top; }
.hc-desc th { background: var(--hc-sky-soft); }
.hc-desc details { border: 1px solid var(--hc-line); border-radius: 10px; padding: 10px 14px; margin: 0 0 .6em; }
.hc-desc summary { cursor: pointer; font-weight: 600; }
.hc-desc details[open] summary { margin-bottom: .5em; }
.hc-desc .hc-refs { font-size: .92rem; color: var(--hc-muted); }

/* ========== 10. TOMBOL DESKRIPSI MELAYANG (#Tombol_Deskripsi) ========== */
.hc-fab {
  position: fixed;
  z-index: 9990;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-weight: 700;
  color: #fff;
  background: var(--hc-navy);
  border: 2px solid var(--hc-sky);
  box-shadow: 0 6px 20px rgba(8, 31, 69, .35);
  cursor: pointer;
  touch-action: manipulation;
  transition: opacity .2s ease, transform .2s ease;
}
.hc-fab svg { width: 20px; height: 20px; flex: 0 0 20px; }
.hc-fab.is-hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }

/* Desktop / tablet: bookmark tegak di tepi kanan */
@media (min-width: 700px) {
  .hc-fab {
    right: 0;
    top: 46%;
    writing-mode: vertical-rl;
    padding: 16px 10px;
    border-right: 0;
    border-radius: 12px 0 0 12px;
    letter-spacing: .04em;
  }
  .hc-fab svg { transform: rotate(90deg); }
  .hc-fab:hover { padding-right: 16px; }
}
/* HP: tombol melayang di kanan bawah */
@media (max-width: 699px) {
  .hc-fab {
    right: 14px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    min-height: 48px;
    padding: 10px 18px;
    border-radius: 999px;
  }
}

/* ========== 11. HP: PANEL HASIL STICKY ========== */
@media (max-width: 699px) {
  .hc-hasil {
    position: sticky;
    top: var(--hc-sticky-top);
    z-index: 60;
    min-height: 0;
    padding: 10px 14px 12px;
    box-shadow: 0 6px 14px rgba(8, 31, 69, .28);
    border-bottom: 1px solid rgba(255, 255, 255, .18);
  }
  .hc-hasil-head { margin-bottom: 2px; }
  .hc-hasil-title { font-size: .7rem; }
  .hc-copy { min-height: 32px; padding: 2px 12px; font-size: .8rem; }
  .hc-out { flex-basis: 110px; }
  .hc-out-name { font-size: .82rem; }
  .hc-out-val { font-size: clamp(1.5rem, 8vw, 2.1rem); }
  .hc-hasil[data-state="error"] .hc-hasil-hint { display: block; }
  .hc-hasil.is-away { opacity: 0; transform: translateY(-12px); pointer-events: none; }
}

/* ========== 12. POP-UP DESKRIPSI (HP) ========== */
html.hc-lock, html.hc-lock body { overflow: hidden !important; }
.hc-modal {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  background: var(--hc-surface);
  color: var(--hc-ink);
  font-family: inherit;
  animation: hc-pop .18s ease-out;
}
.hc-modal-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 14px 10px;
  background: var(--hc-navy);
  color: #fff;
}
.hc-modal-close {                                  /* tombol close (x) di kiri atas */
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  font-size: 1.6rem;
  line-height: 1;
  color: #fff;
  background: rgba(255, 255, 255, .14);
  border: 1px solid rgba(255, 255, 255, .5);
  border-radius: 50%;
  cursor: pointer;
}
.hc-modal-title { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hc-modal-body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 16px calc(24px + env(safe-area-inset-bottom, 0px));
  line-height: 1.75;
}
.hc-modal-body .hc-desc { border: 0; padding: 0; background: transparent; }
@keyframes hc-pop { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* ========== 13. AKSESIBILITAS & PRINT ========== */
.hc-sr { position: absolute !important; width: 1px; height: 1px; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; padding: 0; }
@media (prefers-reduced-motion: reduce) {
  .hc-app *, .hc-modal, .hc-fab { transition: none !important; animation: none !important; }
}
@media print {
  .hc-fab, .hc-tools, .hc-chip-info, .hc-copy, .hc-sign { display: none !important; }
  .hc-app { display: block; background: #fff; width: auto !important; max-width: 100% !important; margin-left: 0 !important; margin-right: 0 !important; }
  .hc-hasil { position: static; box-shadow: none; }
}

/* ========== 14. HP: MANFAATKAN LEBAR LAYAR (revisi v1.0.1, diperbaiki v1.0.2/1.0.3) ==========
 * Area kosong kiri-kanan dikecilkan: kalkulator dilebarkan sampai tepi layar
 * (mengabaikan padding kontainer tema), padding luar dan padding kartu dipersempit.
 * Jika tema Anda sudah full-width atau efek ini tidak diinginkan, tambahkan class
 * "hc-no-bleed" pada .hc-app, atau ubah --hc-hp-edge (jarak ke tepi layar). */
@media (max-width: 699px) {
  :root { --hc-hp-edge: 6px; --hc-gap: 12px; }
  /* pengaman: tidak ada geser kanan/kiri (clip tidak membuat scroll container, sticky tetap jalan) */
  html.hc-has-app, html.hc-has-app body { overflow-x: clip; max-width: 100%; }
  .hc-app, .hc-app > * { min-width: 0; }
  .hc-app:not(.hc-no-bleed) {
    /* --hc-bleed-left / --hc-bleed-w diisi core.js (posisi kiri nyata + lebar layar tanpa scrollbar).
       Digeser dengan position:relative + left (bukan margin) karena tema blok WordPress sering
       memaksa margin:auto !important dan max-width pada anak kontainer. Bila JS belum jalan,
       jatuh ke lebar normal 100% tanpa geseran. */
    position: relative !important;
    left: calc(-1 * var(--hc-bleed-left, 0px)) !important;
    width: var(--hc-bleed-w, 100%) !important;
    min-width: 0 !important;
    max-width: none !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 8px var(--hc-hp-edge) 12px;
    border-radius: 0;
  }
  .hc-app.hc-no-bleed { padding: 8px var(--hc-hp-edge) 12px; border-radius: 12px; }
  .hc-card { padding: 12px 12px; border-radius: 14px; }
  .hc-hasil { border-radius: 14px; padding-left: 12px; padding-right: 12px; }
  .hc-desc { padding: 14px 12px; border-radius: 14px; }
  .hc-top { padding: 0 6px; }
  .hc-fields { gap: 12px; }
  .hc-chips { gap: 8px; }
  .hc-chip { padding: 8px 11px; gap: 6px; }
}
