/* styles.css  (FULL - updated with Egyptian-inspired color theme)
   ============================================================
   FONT: NewGardiner (PUA-only) + Noto for Unicode hieroglyphs
   UI: Noto Sans for transliteration characters ꜣ ꜥ ʾ etc.
   ============================================================ */

/* NewGardiner PUA (BMP) */
@font-face {
  font-family: "NewGardiner";
  src: url("https://cdn.jsdelivr.net/gh/mitsof/NewGardiner@main/NewGardinerBMP.ttf") format("truetype");
  font-display: swap;
  unicode-range: U+E000-E42E;
}

/* Noto: hieroglyphs + UI */
@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+Egyptian+Hieroglyphs&family=Noto+Sans:wght@400;700;800&display=swap");

:root {
  --unitH: 64px;
  --pad: 6px;
  --gap: 8px;
  --uiFont: "Noto Sans", system-ui, -apple-system, "Segoe UI", Arial, sans-serif;

  /* Egyptian-inspired theme colors */
  --sand: #f5f0e1;              /* light papyrus / limestone */
  --sand-dark: #e8dfc8;         /* hover / section bg */
  --papyrus: #fdf9f0;           /* very light output / tile bg */
  --gold: #d4a017;              /* warm gold – active, pinned, accents */
  --gold-dark: #b8860b;         /* darker gold for pressed states */
  --nile-blue: #1a3c5e;         /* deep Egyptian blue – primary actions */
  --nile-blue-light: #2b5a8a;   /* blue hover */
  --accent-red: #a6281e;        /* red ochre – delete/clear */
  --text-dark: #2c1e0f;         /* dark brown-black text */
  --border-subtle: rgba(140, 110, 60, 0.28);  /* aged bronze/sepia */
  --shadow-soft: 0 3px 10px rgba(0,0,0,0.08);
}

body {
  margin: 0;
  font-family: var(--uiFont);
  background: var(--sand);
  color: var(--text-dark);
}

/* =======================
   TOP DOCK (sticky: output + tools)
======================= */

.topDock {
  position: sticky;
  top: 0;
  z-index: 1200;
  background: rgba(245, 240, 225, 0.97);
  backdrop-filter: saturate(1.3) blur(4px);
  border-bottom: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
}

/* =======================
   OUTPUT (max 4 rows + internal scroll)
======================= */

#outputBox {
  width: 100%;
  box-sizing: border-box;
  padding: 10px;
  padding-top: 18px;
  padding-left: calc(10px + env(safe-area-inset-left, 0px));
  padding-right: calc(10px + env(safe-area-inset-right, 0px));
  border-bottom: 1px solid var(--border-subtle);
  min-height: 130px;
  display: flex;
  flex-wrap: wrap;
  gap: var(--gap);
  align-items: flex-start;
  user-select: none;
  max-height: calc(
    (var(--unitH) + (var(--pad) * 2)) * 4 +
    (var(--gap) * 3) +
    20px
  );
  overflow-y: auto;
  overscroll-behavior: contain;
  background: rgba(253, 249, 240, 0.82);
}

/* body content */
.controlsWrap {
  padding: 12px;
}

/* =======================
   COLLAPSIBLE SECTIONS (Tools / Pinned)
======================= */

.sec {
  border-bottom: 1px solid var(--border-subtle);
}

.secHead {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border: 0;
  background: transparent;
  font-family: var(--uiFont);
  font-weight: 900;
  font-size: 12px;
  letter-spacing: .02em;
  color: var(--nile-blue);
  cursor: pointer;
  user-select: none;
}

.secHead:hover {
  color: var(--gold-dark);
}

.secHead:active {
  transform: scale(0.99);
}

.secChevron {
  font-size: 14px;
  opacity: .75;
  transition: transform .15s ease;
}

.sec.collapsed .secChevron {
  transform: rotate(-90deg);
}

.secBody {
  padding: 0 12px 10px;
}

.sec.collapsed .secBody {
  display: none;
}

/* =======================
   SPECIAL KEYS (COMPACT)
======================= */

.special-keys {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 6px 0 0;
}

.key-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 6px;
}

.skey {
  font-family: var(--uiFont);
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(232, 225, 200, 0.9);
  padding: 6px 4px;
  min-height: 40px;
  font-weight: 900;
  font-size: 11px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  color: var(--text-dark);
}

.skey:hover,
.skey:focus {
  background: var(--sand-dark);
  border-color: var(--gold);
}

.skey:active {
  background: var(--gold);
  color: white;
  transform: scale(0.97);
}

.skey:disabled {
  opacity: .5;
  cursor: not-allowed;
}

.skey .icon {
  font-size: 14px;
  line-height: 1;
}

/* Action-specific colors */
#deleteBtn,
#clearBtn {
  color: var(--accent-red);
}

#deleteBtn:active,
#clearBtn:active {
  background: var(--accent-red);
  color: white;
}

#exportSvgBtn,
#exportPngBtn,
#exportJsonBtn {
  color: var(--nile-blue);
}

#exportSvgBtn:active,
#exportPngBtn:active,
#exportJsonBtn:active {
  background: var(--nile-blue);
  color: white;
}

/* =======================
   TABS STRIP
======================= */

.tabs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 6px 0 10px;
  margin: 8px 0 6px;
  -webkit-overflow-scrolling: touch;
}

.tab {
  flex: 0 0 auto;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-subtle);
  background: rgba(232, 225, 200, 0.7);
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  line-height: 1;
  font-family: var(--uiFont);
  color: var(--text-dark);
}

.tab.active {
  background: var(--gold);
  color: white;
  border-color: var(--gold-dark);
}

/* =======================
   SEARCH BAR (+ Uniliterals toggle)
======================= */

.searchWrap {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 6px 0 8px;
}

.searchInput {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(253, 249, 240, 0.9);
  font-weight: 700;
  font-size: 13px;
  outline: none;
  font-family: var(--uiFont);
  color: var(--text-dark);
}

.searchInput:focus {
  background: white;
  border-color: var(--gold);
}

.searchClear {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: 1px solid var(--border-subtle);
  background: rgba(232, 225, 200, 0.9);
  cursor: pointer;
  font-weight: 900;
  line-height: 1;
  font-family: var(--uiFont);
  color: var(--text-dark);
}

.searchClear:active {
  transform: scale(0.97);
}

.searchClear.active {
  background: var(--sand-dark);
}

/* =======================
   OPTIONS ROW
======================= */

.optsRow {
  display: flex;
  gap: 14px;
  align-items: center;
  margin: 0 0 10px;
}

.optToggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 900;
  opacity: .75;
  user-select: none;
  font-family: var(--uiFont);
}

.optToggle input {
  transform: scale(1.1);
}

/* =======================
   HINT
======================= */

.hint {
  font-size: 12px;
  opacity: .75;
  margin: 6px 0 12px;
  line-height: 1.3;
  font-family: var(--uiFont);
}

/* =======================
   FAVORITES BAR
======================= */

.favBar {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 6px 0 2px;
  margin: 0;
  -webkit-overflow-scrolling: touch;
}

.favBar:empty {
  padding: 6px 0 0;
  opacity: .65;
}

.favBar:empty::before {
  content: "No pinned glyphs yet.";
  font-size: 12px;
}

/* =======================
   MAIN GLYPH GRID
======================= */

.glyph-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(42px, 1fr));
  gap: 14px 6px;
  margin-bottom: 10px;
}

.glyphKey {
  position: relative;
  width: 100%;
  min-height: 40px;
  padding-top: 12px;
  padding-right: 10px;
}

.glyphKey .glyph-btn {
  width: 100%;
  font-family: "NewGardiner", "Noto Sans Egyptian Hieroglyphs", "Segoe UI Historic", serif;
  font-size: 26px;
  line-height: 1;
  padding: 6px 4px;
  min-height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border-subtle);
  background: rgba(253, 249, 240, 0.82);
  cursor: pointer;
  user-select: none;
  color: var(--text-dark);
}

.glyph-btn:hover {
  background: var(--sand-dark);
  border-color: var(--gold);
}

.glyph-btn:active {
  background: var(--gold);
  color: white;
}

/* PIN outside key */
.pinBtn {
  position: absolute;
  top: 0;
  right: 0;
  transform: translate(30%, -30%);
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: rgba(253, 249, 240, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s ease;
  color: var(--text-dark);
}

.glyphKey.pinned .pinBtn {
  opacity: 1;
  background: var(--gold);
  color: white;
  border-color: var(--gold-dark);
}

@media (hover: hover) {
  .glyphKey:hover .pinBtn {
    opacity: .75;
  }
}

.glyphKey:active .pinBtn {
  opacity: .75;
}

.glyphKey.pinned .glyph-btn {
  background: rgba(212, 160, 23, 0.18);
  border-color: var(--gold);
}

/* Favorites compact chips */
.favBar .glyphKey {
  width: auto !important;
  min-width: 0 !important;
  flex: 0 0 auto !important;
  padding-top: 10px !important;
  padding-right: 0 !important;
  min-height: 32px !important;
  display: inline-flex !important;
  align-items: center !important;
}

.favBar .glyphKey .glyph-btn {
  width: auto !important;
  min-width: 34px !important;
  min-height: 32px !important;
  padding: 4px 8px !important;
  font-size: 22px !important;
  border-radius: 999px !important;
}

.favBar .glyphKey .pinBtn {
  width: 18px !important;
  height: 18px !important;
  font-size: 11px !important;
  transform: translate(20%, -20%) !important;
  opacity: .85 !important;
}

/* Gardiner code + phonetic labels */
.keyCode {
  position: absolute;
  left: -2px;
  bottom: -10px;
  font-size: 9px;
  font-weight: 900;
  opacity: .7;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--uiFont);
}

.keyPhon {
  position: absolute;
  top: 0px;
  left: 6px;
  font-size: 10px;
  font-weight: 900;
  opacity: .75;
  pointer-events: none;
  white-space: nowrap;
  font-family: var(--uiFont);
}

.keyCode.hidden,
.keyPhon.hidden {
  display: none;
}

/* =======================
   OUTPUT TILES
======================= */

.tile {
  border: 1px solid var(--border-subtle);
  border-radius: 12px;
  padding: var(--pad);
  height: calc(var(--unitH) + (var(--pad) * 2));
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(253, 249, 240, 0.75);
  box-sizing: border-box;
  position: relative;
}

.tile.selected {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
  background: rgba(253, 249, 240, 0.95);
}

/* If an old inside-badge element still exists somewhere, hide it */
.tile .badge {
  display: none !important;
}

/* Badge OUTSIDE tile top-right */
.tile[data-badge]::after {
  content: attr(data-badge);
  position: absolute;
  top: -10px;
  right: -10px;
  z-index: 10;
  pointer-events: none;
  font-size: 12px;
  font-weight: 900;
  opacity: .75;
  font-family: var(--uiFont);
  background: rgba(253, 249, 240, 0.95);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  padding: 2px 6px;
  line-height: 1;
  color: var(--text-dark);
}

/* =======================
   STACKING BLOCKS
======================= */

.blkOuter {
  position: relative;
  display: inline-block;
}

.blkInner {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: top left;
  display: inline-flex;
  align-items: center;
}

.blkInner.v {
  flex-direction: column;
}

.blkInner.h {
  flex-direction: row;
}

.blkInner svg {
  display: block;
}

svg text {
  font-family: "NewGardiner", "Noto Sans Egyptian Hieroglyphs", "Segoe UI Historic", serif !important;
}

/* =======================
   CARTOUCHE
======================= */

.cartOuter {
  position: relative;
  display: inline-block;
  height: var(--unitH);
}

.cartSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cartContent {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

/* =======================
   TOAST
======================= */

.toast {
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  background: var(--nile-blue);
  color: white;
  padding: 10px 12px;
  border-radius: 999px;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
  z-index: 10000;
  font-family: var(--uiFont);
}

.toast.show {
  opacity: 1;
}

/* ============================================================
   ANCIENT EGYPTIAN LOOK (ADD AT END)
   - papyrus texture + vignette
   - carved/inked glyph feel
   - stone/bronze UI accents
============================================================ */

/* Subtle papyrus texture + vignette (no external images) */
body {
  background:
    radial-gradient(1200px 700px at 20% 0%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(900px 600px at 80% 20%, rgba(255,255,255,0.25), transparent 65%),
    radial-gradient(900px 650px at 50% 100%, rgba(0,0,0,0.08), transparent 70%),
    repeating-linear-gradient(
      12deg,
      rgba(140, 110, 60, 0.045) 0px,
      rgba(140, 110, 60, 0.045) 2px,
      rgba(253, 249, 240, 0.0) 7px,
      rgba(253, 249, 240, 0.0) 14px
    ),
    var(--sand);
}

/* Slightly warmer “papyrus sheet” feel for the sticky dock and output */
.topDock {
  background:
    linear-gradient(to bottom, rgba(253,249,240,0.92), rgba(245,240,225,0.96)),
    repeating-linear-gradient(
      0deg,
      rgba(140,110,60,0.05) 0px,
      rgba(140,110,60,0.05) 1px,
      rgba(0,0,0,0) 8px,
      rgba(0,0,0,0) 14px
    );
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

#outputBox {
  background:
    radial-gradient(800px 280px at 50% 0%, rgba(255,255,255,0.55), rgba(0,0,0,0) 60%),
    repeating-linear-gradient(
      90deg,
      rgba(140,110,60,0.03) 0px,
      rgba(140,110,60,0.03) 2px,
      rgba(0,0,0,0) 10px,
      rgba(0,0,0,0) 18px
    ),
    rgba(253, 249, 240, 0.86);
  border-bottom-color: rgba(140, 110, 60, 0.38);
}

/* Tiles feel like carved limestone blocks */
.tile {
  background:
    radial-gradient(140px 70px at 30% 20%, rgba(255,255,255,0.7), rgba(255,255,255,0.0) 60%),
    linear-gradient(to bottom, rgba(253,249,240,0.92), rgba(232,223,200,0.60));
  border-color: rgba(120, 90, 45, 0.35);
  box-shadow:
    0 2px 0 rgba(255,255,255,0.55) inset,
    0 -2px 0 rgba(0,0,0,0.05) inset,
    0 8px 18px rgba(0,0,0,0.08);
}

.tile.selected {
  outline-color: var(--gold);
  box-shadow:
    0 2px 0 rgba(255,255,255,0.55) inset,
    0 -2px 0 rgba(0,0,0,0.05) inset,
    0 10px 22px rgba(0,0,0,0.12);
}

/* Badge feels like a wax/bronze seal */
.tile[data-badge]::after {
  background:
    radial-gradient(circle at 30% 30%, rgba(255,255,255,0.65), rgba(255,255,255,0) 55%),
    linear-gradient(to bottom, rgba(253,249,240,0.95), rgba(232,223,200,0.95));
  border-color: rgba(120, 90, 45, 0.40);
  box-shadow: 0 6px 14px rgba(0,0,0,0.12);
}

/* Buttons: more “bronze tooling” */
.skey,
.tab,
.searchClear,
.glyphKey .glyph-btn {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.55) inset,
    0 -1px 0 rgba(0,0,0,0.05) inset,
    0 6px 14px rgba(0,0,0,0.08);
}

/* Make active states feel like gilded inlay */
.skey:active,
.tab.active,
.glyph-btn:active {
  box-shadow:
    0 1px 0 rgba(255,255,255,0.25) inset,
    0 10px 18px rgba(0,0,0,0.10);
}

/* Glyphs: inked + slightly carved effect */
svg text {
  /* dark ink */
  fill: rgba(44, 30, 15, 0.98);
  /* subtle “carved edge” illusion */
  text-shadow:
    0.7px 0.7px 0 rgba(255,255,255,0.35),
    -0.7px -0.7px 0 rgba(0,0,0,0.08),
    1.2px 1.2px 0 rgba(0,0,0,0.06);
}

/* Slightly reduce the “too crisp” look of vectors */
.blkOuter svg {
  filter: contrast(1.05) saturate(0.95);
}

/* Section headers more chiseled */
.secHead {
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(26, 60, 94, 0.92);
}

/* Inputs: parchment */
.searchInput {
  background:
    linear-gradient(to bottom, rgba(255,255,255,0.85), rgba(253,249,240,0.92));
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    0 10px 18px rgba(0,0,0,0.06);
}

/* Scrollbars (webkit) */
#outputBox::-webkit-scrollbar,
.tabs::-webkit-scrollbar,
.favBar::-webkit-scrollbar {
  height: 10px;
  width: 10px;
}

#outputBox::-webkit-scrollbar-thumb,
.tabs::-webkit-scrollbar-thumb,
.favBar::-webkit-scrollbar-thumb {
  background: rgba(140, 110, 60, 0.35);
  border-radius: 999px;
  border: 2px solid rgba(253, 249, 240, 0.75);
}

#outputBox::-webkit-scrollbar-track,
.tabs::-webkit-scrollbar-track,
.favBar::-webkit-scrollbar-track {
  background: rgba(232, 223, 200, 0.45);
  border-radius: 999px;
}

/* Respect reduced motion */
@media (prefers-reduced-motion: reduce) {
  .secChevron {
    transition: none !important;
  }
}

/* ============================================================
   SPECIAL KEYS: slightly longer to fit text (ONLY special keys)
   ADD AT END
============================================================ */

/* Make special keys roomier horizontally */
.skey {
  padding: 7px 12px;     /* more horizontal space for labels */
  min-height: 42px;      /* a touch taller */
  line-height: 1.1;
}

/* Let special keys grow wider so text doesn't get cramped */
.key-row {
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr)); /* was 42px */
}

/* Allow wrapping for long special-key labels only */
.skey {
  white-space: normal;  /* overrides nowrap only for special keys */
  text-align: center;
}




