/* --- Base layout & typography --- */

:root {
  --gold: #feda15;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: 'Noto Sans', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.6;
  color: #1b2533;
  background: radial-gradient(circle at top, #1c3a63 0, #050814 55%, #050814 100%);
  display: flex;
  flex-direction: column;
}

/* ===========================
   Hela Nomad Header Styling
   =========================== */

.site-header {
  background: transparent;
  /* Let your global dark bg show */
  padding: 18px 0 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.site-header-inner {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
}

/* --- GOLD Main Title --- */
.brand-title {
  font-weight: 700;
  color: var(--gold);
  text-decoration: none;
}

.brand-title:hover {
  opacity: 0.92;
}

.brand-link {
  color: rgba(255, 255, 255, 0.75);
  text-decoration: none;
}

.brand-link:hover {
  color: var(--gold);
  opacity: 0.95;
}

/* Divider slash */
.brand-divider {
  color: rgba(255, 255, 255, 0.3);
}

/* Section label (non-clickable) */
.brand-section {
  color: rgba(255, 255, 255, 0.55);
}

/* HERO SECTION (Title and subtitle) */
.hero-content {
  margin-top: 8px;
}

.hero-title {
  font-size: 30px;
  font-weight: 600;
  color: #f9fafb;
  margin: 0;
}

.hero-subtitle {
  margin-top: 4px;
  font-size: 16px;
  color: rgba(255, 255, 255, 0.75);
  max-width: 680px;
}

.hero-subtitle strong {
  font-weight: 600;
}

.hero-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hero-tag {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  background: rgba(5, 92, 157, 0.18);
  border: 1px solid rgba(245, 249, 255, 0.2);
  border-radius: 999px;
  padding: 4px 10px;
  backdrop-filter: blur(4px);
}

/* --- Main layout --- */

.page-main {
  max-width: 100%;
  margin: -24px auto 40px;
  padding: 0 16px 40px;
  flex: 1;
  /* this pushes the footer down */
}

/* --- Tool card --- */

.tool-card {
  margin-top: 10px;
  margin-bottom: 24px;
}

.tool-card-inner {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
  padding: 20px 18px 18px;
}

@media (min-width: 720px) {
  .tool-card-inner {
    padding: 24px 22px 20px;
  }
}

.input-block {
  margin-bottom: 16px;
}

.input-label {
  display: block;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #4b5563;
  margin-bottom: 6px;
}

.input-field {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d0d7e2;
  font-size: 16px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.08s ease;
}

.input-field::placeholder {
  color: #9ca3af;
}

.input-field:focus {
  border-color: #055c9d;
  box-shadow: 0 0 0 2px rgba(5, 92, 157, 0.18);
  transform: translateY(-1px);
}

/* --- Table styling --- */

.table-block {
  margin-top: 16px;
}

.table-scroll {
  width: 100%;
  border-radius: 12px;
  border: 1px solid #e3e8ef;
  max-height: 70vh;
  overflow-y: auto;
  overflow-x: auto;
}

.input-toolbar {
  background: #f3f4f6;
  /* soft grey */
  padding: 10px 14px;
  margin-top: 10px;
  margin-bottom: 18px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}

/* Flex inner layout */
.toolbar-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  /* stack hint + toggles */
  align-items: center;
  /* center horizontally */
  justify-content: center;
  gap: 8px;
  text-align: center;
  /* center the hint text */
}

/* Hint text styling */
.toolbar-inner .input-hint {
  margin: 0;
  font-size: 15px;
  color: #47536b;
  line-height: 1.4;
}

.toolbar-toggles {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 30px;
  justify-content: center;
  /* center toggles */
  align-items: center;
}

/* Keep your toggle styles as they are */

/* Toggle switch container */
.view-toggle {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
}

/* Make sure the toggle switch itself never shrinks */
.view-toggle .switch {
  flex-shrink: 0;
}

/* Text next to toggle */
.toggle-text {
  font-size: 14px;
  color: #374151;
  opacity: 1;
  transition: opacity 0.2s ease;
  user-select: none;
}

/* When syllables are collapsed, only dim the syllable toggle label */
body.collapsed-syllables .view-toggle--syllables .toggle-text {
  opacity: 0.45;
}

/* When syllables are collapsed, only dim the syllable toggle label */
body.collapsed-sannaka .view-toggle--sannaka .toggle-text {
  opacity: 0.45;
}

/* Switch wrapper */
.switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

/* Hide the original checkbox */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

/* Slider track */
.slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cfd6df;
  border-radius: 24px;
  transition: 0.3s;
}

/* Knob */
.slider::before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background-color: #ffffff;
  border-radius: 50%;
  transition: 0.3s;
  box-shadow: 0px 1px 4px rgba(0, 0, 0, 0.25);
}

/* When checked: blue track */
.switch input:checked+.slider {
  background-color: #055c9d;
}

/* When checked: knob slides right */
.switch input:checked+.slider::before {
  transform: translateX(20px);
}

/* Normal syllable rows: visible, with a transition */
#output tbody tr.syllable-row td {
  transition: opacity 0.18s ease, padding 0.18s ease, font-size 0.18s ease, border-width 0.18s ease;
}

/* When collapsed: fade and gently compress syllable rows */
body.collapsed-syllables #output tbody tr.syllable-row td {
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
  font-size: 0;
  border-width: 0;
}

/* Keep id and structure for JS compatibility */
#output {
  width: 100%;
  border-collapse: collapse;
  background: #ffffff;
  min-width: 540px;
}

#output thead th {
  background-color: #055c9d;
  color: #f0f8ff;
  font-weight: 600;
  font-size: 20px;
  padding: 10px 12px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 5;
}

#output th:first-child {
  border-top-left-radius: 12px;
}

#output th:last-child {
  border-top-right-radius: 12px;
}

#output tbody td {
  padding: 10px 12px;
  text-align: center;
  border-bottom: 1px solid #edf1f7;
  font-size: 22px;
}

#output tbody tr:nth-child(even) {
  background-color: #f7fafc;
}

#output tbody tr:hover:not(.full-word):not(.spacer) {
  background: #e9f3ff;
}

#output td {
  white-space: nowrap;
}

#output td.brahmi {
  font-family: 'Noto Sans Brahmi', sans-serif;
  white-space: nowrap;
}

#output td.sinhala {
  font-family: 'Noto Sans Sinhala', sans-serif;
}

#output td.tamil {
  font-family: 'Noto Sans Tamil', sans-serif;
}

#output td.devanagari {
  font-family: 'Noto Sans Devanagari', sans-serif;
}

/* Full-word row */
#output tbody tr.full-word td {
  background-color: #003060;
  color: #e0f7fa;
  font-size: 24px;
  font-weight: 600;
  border-top: 1px solid #0f172a;
  border-bottom: 1px solid #0f172a;
}

#output tbody tr.full-word td:first-child {
  text-transform: lowercase;
}

#output tbody tr.full-word strong {
  color: #fefce8;
}

/* Spacer row */
#output tbody tr.spacer td {
  padding: 0px !important;
  background-color: transparent !important;
  border-bottom: none !important;
}

.table-hint {
  margin: 10px 4px 0;
  font-size: 14px;
  color: #4b5563;
}

.diacritics-hint {
  margin: 4px 4px 0;
  font-size: 14px;
  color: #4b5563;
  text-align: center;
  line-height: 1.4;
}

/* --- Help / info section --- */

.help-section {
  margin-top: 10px;
}

.help-card {
  background: rgba(15, 23, 42, 0.88);
  border-radius: 18px;
  padding: 16px 16px 14px;
  color: #e5e7eb;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

@media (min-width: 720px) {
  .help-card {
    padding: 18px 20px 16px;
  }
}

.help-title {
  font-size: 15px;
  margin: 0 0 6px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f9fafb;
}

.help-list {
  margin: 4px 0 0;
  padding-left: 18px;
  font-size: 16px;
}

.help-list li+li {
  margin-top: 3px;
}

.help-list code {
  background: rgba(15, 23, 42, 0.75);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 12px;
}

.help-divider {
  border: none;
  border-top: 1px solid rgba(148, 163, 184, 0.25);
  margin: 14px 0 18px;
}

/* --- Help - Special Chars --- */
.special-chars-table {
  width: 100%;
  max-width: 480px;
  margin: 14px auto 0;
  border-collapse: collapse;
  background: rgba(255, 255, 255, 0.02);
}

.special-chars-title {
  margin: 16px 0 0 0;
}

.special-chars-table th {
  text-align: left;
  font-size: 13px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #cbd5e1;
  padding: 6px 8px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.25);
}

.special-chars-table td {
  padding: 6px 8px;
  font-size: 22px;
  color: #e5e7eb;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  vertical-align: middle;
  white-space: nowrap;
}

/* Special Characters table: second column (Meaning) */
.special-chars-table td:nth-child(2) {
  font-size: 16px;
  /* ← choose your size */
  color: #d1d5db;
  /* optional: softer grey */
  font-weight: 500;
  /* optional: slightly refined weight */
}

.special-chars-table tr:last-child td {
  border-bottom: none;
}

.special-chars-note {
  font-size: 16px;
  color: #9ca3af;
  text-align: left;
  margin-top: 1px;
  margin-bottom: 0px;
}

.special-highlight {
  margin: 10px 0 16px 0;
  padding: 6px 6px;
  background: rgba(254, 218, 21, 0.12);
  /* gold tint */
  border-left: 3px solid var(--gold);
  border-radius: 6px;
  color: #f1f5f9;
  font-size: 16px;
  font-feature-settings: "locl";
}

.special-highlight strong {
  color: var(--gold);
}

.special-highlight [lang="si"] {
  font-family: 'Noto Sans Sinhala', sans-serif;
}

/* Sinhala gold output */
.sc-gold {
  color: var(--gold);
  font-size: 22px;
  font-family: 'Noto Sans Sinhala', sans-serif;
}

/* Pills reused from earlier */
.pill {
  display: inline-block;
  padding: 2px 6px;
  margin-left: 4px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #e5e7eb;
}

.pill.iast {
  background: rgba(100, 181, 246, 0.15);
  border-color: rgba(100, 181, 246, 0.25);
}

.pill.iso {
  background: rgba(167, 139, 250, 0.15);
  border-color: rgba(167, 139, 250, 0.25);
}

.pill.german {
  background: rgba(254, 218, 21, 0.12);
  border-color: rgba(254, 218, 21, 0.25);
  color: var(--gold);
}

/* --- Help - Sannaka mapping --- */
.sannaka-mapping {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(148, 163, 184, 0.3);
}

/* Title */
.sannaka-title {
  font-size: 16px;
  margin: 0 0 0;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f1f5f9;
  text-align: left;
}

/* Compact table wrapper */
.sannaka-table {
  border-collapse: collapse;
  margin: 0 auto 8px auto;
  /* center table */
  width: auto;
  /* shrink to content */
  max-width: 260px;
  /* prevent it from getting too wide */
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
}

/* Cells */
.sannaka-table th,
.sannaka-table td {
  padding: 6px 10px;
  font-size: 22px;
  color: #e5e7eb;
  border-bottom: 1px solid rgba(148, 163, 184, 0.18);
  white-space: nowrap;
  text-align: center;
}

.sannaka-table th {
  text-align: center;
  color: #cbd5e1;
  font-weight: 300;
  border-bottom: 1px solid rgba(148, 163, 184, 0.3);
  letter-spacing: 0.06em;
  font-size: 13px;
  text-transform: uppercase;
}

/* Result column */
.sannaka-table td:last-child {
  font-family: 'Noto Sans Sinhala', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--gold);
}

/* Last row: remove border */
.sannaka-table tr:last-child td {
  border-bottom: none;
}

.sannaka-note {
  font-size: 16px;
  color: #9ca3af;
  text-align: left;
  margin-top: 1px;
}

.highlight-gold {
  color: var(--gold);
  font-weight: 700;
}

.dev-highlight {
  border-left-color: #60a5fa;
  /* soft blue instead of gold */
  background: rgba(96, 165, 250, 0.08);
  /* light blue tint */
}

.tamil-highlight {
  border-left-color: #f87171;
  /* soft red tint */
  background: rgba(248, 113, 113, 0.08);
  /* light red background */
}

/* --- Footer --- */

.site-footer {
  border-top: 1px solid rgba(148, 163, 184, 0.3);
  padding: 14px 16px 24px;
  color: #e5e7eb;
  background: #050814;
}

.site-footer-inner {
  max-width: 960px;
  margin: 0 auto;
  text-align: center;
}

.footer-text {
  margin: 2px 0;
  font-size: 12px;
  opacity: 0.8;
}

/* ===========================
   SIDE-BY-SIDE LAYOUT (TOOL + LEGEND)
   =========================== */

.tool-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: nowrap;
  margin: 20px auto;
  max-width: 1600px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Left column contains tool + help */
.tool-column {
  flex: 0 0 65%;
  max-width: 65%;
  min-width: 0;
  /* prevents content overflow */
}

.tool-card {
  width: 100%;
}

/* --- Legend --- */

.legend-section {
  flex: 0 0 35%;
  max-width: 35%;
  min-width: 320px;
  overflow: visible;
}

#legend {
  margin-top: 0.5rem;
  font-size: 0.95rem;
  max-width: 960px;
  margin-left: auto;
  margin-right: auto;
}

/* White card like the main tool */
.legend-card {
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.25);
  padding: 16px 16px 18px;
  margin-top: 0;
  max-height: none;
  overflow: visible;
}

@media (min-width: 720px) {
  .legend-card {
    padding: 20px 20px 20px;
  }
}

#legend .section-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

#legend .section-title {
  margin: 0;
}

#legend .section-sub {
  margin: 0;
  opacity: 0.8;
}

#toggle-legend {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f3f4f6;
  cursor: pointer;
  font-size: 0.85rem;
  transition: opacity 0.2s ease;
}

#toggle-legend:active {
  opacity: 0.5;
}

/* Animated collapse */
#legend-content {
  overflow: hidden;
  opacity: 1;
  transition: transform 0.25s ease, opacity 0.25s ease;
  transform: scaleY(1);
  transform-origin: top;
}

/* Collapsed state */
#legend-content.legend-hidden {
  transform: scaleY(0);
  max-height: 0;
  opacity: 0;
}

#legend-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
}

#legend-table th,
#legend-table td {
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.35rem 0.5rem;
  text-align: center;
  color: #1b2533;
  /* dark text */
  background: rgba(255, 255, 255, 0.04);
  font-size: 18px;
}

#legend-table thead {
  background: rgba(255, 255, 255, 0.06);
  color: #f1f5f9;
}

#legend-table thead th {
  background-color: #055c9d;
  color: #f0f8ff;
  font-weight: 600;
  font-size: 18px;
  text-align: center;
  white-space: nowrap;
}

#legend-table thead th:first-child {
  border-top-left-radius: 12px;
}

#legend-table thead th:last-child {
  border-top-right-radius: 12px;
}

#legend-table tr:nth-child(even) td {
  background: #f4f7fb;
}

#legend-table tr:hover td {
  background: #e0eeff;
}

/* Script-specific fonts for legend cells */
#legend-table td.brahmi {
  font-family: 'Noto Sans Brahmi', sans-serif;
}

#legend-table td.sinhala {
  font-family: 'Noto Sans Sinhala', sans-serif;
}

#legend-table td.tamil {
  font-family: 'Noto Sans Tamil', sans-serif;
}

#legend-table td.devanagari {
  font-family: 'Noto Sans Devanagari', sans-serif;
}

.legend-scroll {
  width: 100%;
  overflow-x: auto;
  /* <— horizontal scroll */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  /* smooth on iOS/mac */
  padding-bottom: 4px;
  /* so scrollbar doesn't overlap text */
}

.legend-scroll::-webkit-scrollbar {
  height: 8px;
}

.legend-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 4px;
}

.legend-scroll::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.1);
}

/* ===== Mobile responsiveness ===== */

@media (max-width: 600px) {

  /* Header: tighten spacing, smaller title */
  .site-header {
    padding: 10px 12px 12px;
  }

  .hero-content {
    margin-top: 8px;
  }

  .hero-title {
    font-size: 22px;
  }

  .hero-subtitle {
    font-size: 13px;
    max-width: 100%;
  }

  /* Main layout: reduce side padding */
  .page-main {
    padding: 0 10px 24px;
    margin-top: 12px;
  }

  .tool-card-inner {
    padding: 14px 12px;
    border-radius: 12px;
  }

  /* Input field: slightly smaller text & padding */
  .input-field {
    font-size: 15px;
    padding: 8px 10px;
  }

  /* Diacritics + toggle bar: stack on small screens */
  .input-toolbar,
  .toolbar-inner {
    flex-direction: column;
    align-items: center;
    gap: 6px;
  }

  .toolbar-toggles {
    justify-content: flex-start;
  }

  .view-toggle {
    width: 100%;
    justify-content: flex-start;
    align-items: flex-start;
    gap: 8px;
  }

  .view-toggle .toggle-text {
    flex: 1;
    /* allow the label to wrap under the switch nicely */
  }

  .toggle-text {
    font-size: 13px;
  }

  .input-hint {
    font-size: 13px;
  }

  /* Table container: ensure scroll works nicely */
  .table-scroll {
    border-radius: 10px;
    max-height: 60vh;
  }

  /* Table text: slightly smaller so more fits horizontally */
  #output thead th {
    font-size: 14px;
    padding: 8px 6px;
  }

  #output tbody td {
    font-size: 18px;
    padding: 6px 6px;
  }

  /* Full-word row: still prominent but not huge */
  #output tbody tr.full-word td {
    font-size: 20px;
  }

  /* Help card: lighter footprint */
  .help-card {
    padding: 10px 12px;
    border-radius: 10px;
  }

  .help-list {
    font-size: 13px;
  }

  /* Special characters table – mobile adjustments */
  .special-chars-table {
    max-width: 100%;
    margin-top: 10px;
  }

  .special-chars-table th {
    font-size: 11px;
    padding: 4px 4px;
  }

  .special-chars-table td {
    font-size: 14px;
    padding: 4px 4px;
    white-space: normal;
    /* allow wrapping on small screens */
  }

  .sc-gold {
    font-size: 18px;
    /* a bit smaller but still prominent */
  }

  /* Sannaka table – mobile adjustments */
  .sannaka-table {
    max-width: 100%;
    width: 100%;
    margin-top: 10px;
    border-radius: 6px;
  }

  .sannaka-table th {
    font-size: 11px;
    padding: 4px 6px;
    letter-spacing: 0.04em;
  }

  .sannaka-table td {
    font-size: 16px;
    /* was 22px */
    padding: 4px 6px;
    white-space: normal;
    /* allow line breaking */
  }

  /* Sinhala output stays gold + slightly smaller */
  .sannaka-table td:last-child {
    font-size: 18px;
    /* was 22px */
    font-weight: 600;
  }

  .sannaka-note {
    font-size: 11px;
    line-height: 1.4;
  }
}

@media (max-width: 500px) {
  .toolbar-toggles {
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
  }
}

@media (max-width: 400px) {
  .sannaka-table td {
    font-size: 14px;
  }

  .sannaka-table td:last-child {
    font-size: 16px;
  }
}

@media (max-width: 900px) {
  .tool-layout {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-column,
  .legend-section {
    flex: 0 0 auto;
    width: 100%;
    max-width: 100%;
  }

  /* On mobile, let legend grow like a normal block */
  .legend-card {
    max-height: none;
    overflow: visible;
  }
}