@import url("https://fonts.googleapis.com/css2?family=Cinzel:wght@500;600;700&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&family=IBM+Plex+Mono:wght@400;500&display=swap");

/* ============================================================
   TOKENS — "Attic" (dark, black-figure pottery) default
              "Marble" (light, quarried stone) alternate
   Grounded in Greek antiquity: glazed terracotta pottery,
   papyrus/parchment manuscripts, and inscribed marble.
   ============================================================ */
:root {
  --pottery-black: #26150f;
  --pottery-black-raised: #1a0f0b;
  --gold: #e7af58;
  --gold-bright: #f2c274;
  --terracotta: #ba4d43;
  --terracotta-bright: #d4645a;
  --papyrus: #ecddc3;
  --ink: #2e2418;
  --ink-dim: #6b5d48;
  --bronze: #73532d;
  --line-dark: #4a3524;
  --err: #d4645a;

  --bg: var(--pottery-black);
  --page: var(--pottery-black);
  --page-raised: var(--pottery-black-raised);
  --text: var(--papyrus);
  --text-dim: var(--bronze);
  --accent: var(--gold);
  --accent-bright: var(--gold-bright);
  --accent2: var(--terracotta);
  --accent2-bright: var(--terracotta-bright);
  --on-accent: #241209;
  --line: var(--line-dark);
  --chrome-text: var(--papyrus);
  --chrome-text-dim: #b7a98a;
  --glyph: var(--terracotta);
  --fill-text: #ffffff;

  --font-display: "Cinzel", "Trajan Pro", Georgia, serif;
  --font-body: "EB Garamond", Georgia, serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;

  color-scheme: dark;
}

:root[data-theme="marble"] {
  --bg: #fbf0db;
  --page: #fbf0db;
  --page-raised: #f2e6cc;
  --text: #2e2418;
  --text-dim: #8a7550;
  --accent: #8e241f;
  --accent-bright: #a8322c;
  --accent2: #ebbf76;
  --accent2-bright: #f0cc8f;
  --on-accent: #fbf0db;
  --line: #d9c9a4;
  --chrome-text: #2e2418;
  --chrome-text-dim: #786b52;
  --glyph: #8e241f;
  --fill-text: #000000;
  color-scheme: light;
}

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

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

body {
  background: var(--bg);
  color: var(--chrome-text);
  font-family: var(--font-body);
  transition:
    background 0.35s ease,
    color 0.35s ease;
  -webkit-font-smoothing: antialiased;
}

/* diagonal hazard-stripe texture behind everything, as seen in the
   masthead screenshots */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.05;
  z-index: 0;
  background-image: repeating-linear-gradient(
    45deg,
    var(--chrome-text) 0px,
    var(--chrome-text) 1px,
    transparent 1px,
    transparent 14px
  );
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================
   DECORATIVE MEANDER GLYPH STRIP
   Small repeating greek-key icon, reused for the masthead
   flourish, the divider ornaments, and the footer mark. Masked
   so it always matches the current theme's glyph color.
   ============================================================ */
.meander-strip {
  display: inline-block;
  width: 46px;
  height: 12px;
  background-color: var(--glyph);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 0H15V3H9V6H15V9H0V6H6V3H0Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 0H15V3H9V6H15V9H0V6H6V3H0Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: repeat-x;
  mask-repeat: repeat-x;
  -webkit-mask-size: 15px 12px;
  mask-size: 15px 12px;
  -webkit-mask-position: center;
  mask-position: center;
  opacity: 0.9;
}

.meander-dot {
  display: inline-block;
  width: 15px;
  height: 12px;
  background-color: var(--glyph);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 0H15V3H9V6H15V9H0V6H6V3H0Z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 15 12'%3E%3Cpath d='M0 0H15V3H9V6H15V9H0V6H6V3H0Z'/%3E%3C/svg%3E");
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-size: 15px 12px;
  mask-size: 15px 12px;
  -webkit-mask-position: center;
  mask-position: center;
  opacity: 0.9;
  flex-shrink: 0;
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page {
  position: relative;
  z-index: 1;
  max-width: 700px;
  margin: 0 auto;
  padding: 56px 24px 40px;
}

.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 7px 20px;
  cursor: pointer;
  transition:
    background 0.2s ease,
    color 0.2s ease;
}
.theme-toggle:hover {
  background: var(--accent);
  color: var(--on-accent);
}
.theme-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   MASTHEAD — set like the spine of an ancient text
   ============================================================ */
.masthead {
  text-align: center;
  margin-bottom: 26px;
}
.masthead__eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin: 0 0 12px;
}
.masthead__eyebrow-word {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--accent2);
}
.masthead__title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(38px, 9vw, 58px);
  letter-spacing: 0.06em;
  line-height: 1;
  color: var(--chrome-text);
}
.masthead__subtitle {
  margin: 14px 0 20px;
  font-size: 15px;
  color: var(--chrome-text-dim);
  font-style: italic;
  font-family: var(--font-body);
  letter-spacing: 0.02em;
}

/* ============================================================
   CARD — a simple inscribed, bordered page
   ============================================================ */
.card {
  background: var(--page);
  border: 1px solid var(--accent);
  border-radius: 3px;
  padding: 24px 28px 20px;
  box-shadow: 0 30px 70px -30px rgba(0, 0, 0, 0.6);
  position: relative;
}

/* ============================================================
   SEARCH
   ============================================================ */
.search {
  display: flex;
  gap: 10px;
  padding: 0;
}
.search__input {
  flex: 1;
  min-width: 0;
  background: var(--page-raised);
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 17px;
  padding: 12px 16px;
  transition: border-color 0.2s ease;
}
.search__input::placeholder {
  color: var(--text-dim);
  font-style: italic;
}
.search__input:focus {
  outline: none;
  border-color: var(--accent);
}
.search__button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  color: var(--on-accent);
  border: none;
  border-radius: 2px;
  padding: 0 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.1s ease;
}
.search__button:hover {
  background: var(--accent-bright);
}
.search__button:active {
  transform: scale(0.97);
}
.search__button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.search__icon {
  width: 14px;
  height: 14px;
  background-color: var(--on-accent);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.5 3a7.5 7.5 0 015.916 12.1l5.242 5.243a1 1 0 01-1.415 1.414l-5.242-5.242A7.5 7.5 0 1110.5 3zm0 2a5.5 5.5 0 100 11 5.5 5.5 0 000-11z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M10.5 3a7.5 7.5 0 015.916 12.1l5.242 5.243a1 1 0 01-1.415 1.414l-5.242-5.242A7.5 7.5 0 1110.5 3zm0 2a5.5 5.5 0 100 11 5.5 5.5 0 000-11z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  opacity: 0.9;
}
.search__hint {
  min-height: 18px;
  margin: 8px 2px 0;
  font-size: 13px;
  font-style: italic;
  color: var(--err);
}

/* ============================================================
   CHIPS — like small terracotta ostraka (potsherd labels)
   ============================================================ */
.chip-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px dashed var(--line);
}
.chip-row--history {
  padding-top: 12px;
  border-top: none;
  margin-top: 8px;
}
.chip-row__label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent2);
  margin-right: 2px;
  white-space: nowrap;
}
.chip {
  background: transparent;
  border: 1px solid var(--accent2);
  color: var(--fill-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease,
    background 0.15s ease;
}
.chip:hover {
  border-color: var(--accent2-bright);
  color: var(--fill-text);
}
.history-chips button {
  background: var(--accent2);
  border: 1px solid var(--accent2);
  color: var(--fill-text);
  font-family: var(--font-body);
  font-size: 14px;
  font-style: italic;
  padding: 6px 14px;
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.history-chips button:hover {
  background: var(--accent2-bright);
  border-color: var(--accent2-bright);
}
.history-chips {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================
   RESULT AREA / STATES
   ============================================================ */
.result-area {
  margin-top: 22px;
  min-height: 120px;
}

.state {
  padding: 44px 12px 52px;
  text-align: center;
  color: var(--text-dim);
}
.state__mark {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--accent);
  margin: 0 0 8px;
}
.state__mark--error {
  color: var(--err);
}
.state__hint {
  font-size: 13px;
  font-style: italic;
  margin-top: 4px;
}

.spinner {
  width: 26px;
  height: 26px;
  margin: 0 auto 14px;
  border-radius: 50%;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ============================================================
   ENTRY — the illuminated page for a single word
   ============================================================ */
.entry {
  animation: reveal 0.35s ease both;
  padding-bottom: 20px;
}
@keyframes reveal {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.entry__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 4px;
}
.entry__headline {
  flex: 1;
  min-width: 0;
}
.entry__label {
  margin: 0 0 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent2);
}
.entry__word {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 6vw, 38px);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  line-height: 1.05;
}
.entry__pos {
  margin: 8px 0 0;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 14px;
  color: var(--text-dim);
}
.entry__pos::before {
  content: "— ";
}
.entry__pos::after {
  content: " —";
}

.speak-button {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--accent);
  border: none;
  color: var(--on-accent);
  border-radius: 999px;
  padding: 9px 18px;
  font-size: 11px;
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}
.speak-button:hover {
  background: var(--accent-bright);
}
.speak-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.speak-button__icon {
  width: 12px;
  height: 12px;
  background-color: var(--on-accent);
  -webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 5V4L8 9H4z'/%3E%3Cpath d='M16.5 12a4.5 4.5 0 00-2.5-4.03v8.06A4.5 4.5 0 0016.5 12z'/%3E%3Cpath d='M14 4.35v2.06a7 7 0 010 11.18v2.06a9 9 0 000-15.3z'/%3E%3C/svg%3E");
  mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M4 9v6h4l5 5V4L8 9H4z'/%3E%3Cpath d='M16.5 12a4.5 4.5 0 00-2.5-4.03v8.06A4.5 4.5 0 0016.5 12z'/%3E%3Cpath d='M14 4.35v2.06a7 7 0 010 11.18v2.06a9 9 0 000-15.3z'/%3E%3C/svg%3E");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  opacity: 0.9;
}

.entry__phonetic {
  margin: 10px 0 0;
  font-family: var(--font-mono);
  font-size: 16px;
  color: var(--text-dim);
  letter-spacing: 0.01em;
}

.entry__divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 18px 0;
}
.entry__divider::before,
.entry__divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.entry__section {
  padding: 0;
}
.entry__label--section {
  margin: 0 0 12px;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent2);
}

.meaning-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  counter-reset: m;
}
.meaning-list li {
  display: flex;
  gap: 10px;
  font-size: 16px;
  line-height: 1.6;
}
.meaning-list li::before {
  content: counter(m, upper-roman);
  counter-increment: m;
  font-family: var(--font-display);
  font-size: 13px;
  color: var(--accent);
  flex-shrink: 0;
  padding-top: 2px;
}

.entry__example {
  margin: 0;
  font-family: var(--font-body);
  font-style: italic;
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-dim);
}
.entry__example::before {
  content: "\201C";
}
.entry__example::after {
  content: "\201D";
}

.synonym-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.synonym-list span {
  background: var(--accent2);
  border: 1px solid var(--accent2);
  border-radius: 2px;
  padding: 5px 12px;
  font-size: 13px;
  font-style: italic;
  color: var(--fill-text);
}
.synonym-list .synonym-list__empty {
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-dim);
  font-style: italic;
}

.entry__footer {
  display: flex;
  gap: 10px;
}
.icon-button {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  border-radius: 2px;
  padding: 8px 16px;
  font-size: 11px;
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition:
    border-color 0.15s ease,
    color 0.15s ease;
  white-space: nowrap;
}
.icon-button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.colophon {
  text-align: center;
  margin-top: 28px;
}
.colophon__mark {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 10px;
}
.colophon p {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--chrome-text-dim);
  opacity: 0.8;
  font-style: italic;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 560px) {
  .page {
    padding: 44px 16px 32px;
  }
  .card {
    padding: 20px 18px 16px;
  }
  .search {
    flex-direction: column;
  }
  .search__button {
    justify-content: center;
    padding: 13px;
  }
  .entry__head {
    flex-wrap: wrap;
  }
  .masthead__eyebrow-word {
    font-size: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}
