/* ---------- Design tokens ---------- */
:root {
  --paper: #f6f0e7;
  --paper-deep: #ede3d5;
  --surface: #fffaf3;
  --ink: #26231f;
  --muted: #6f675e;
  --line: #d8cdbf;
  --accent: #85563e;
  --accent-dark: #633d2d;
  --accent-soft: #dfc3ac;
  --olive: #72715a;
  --shadow: 0 18px 50px rgba(64, 46, 35, 0.09);
  --radius: 18px;
  --shell: min(1180px, calc(100% - 40px));
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
  line-height: 1.6;
}
body.modal-open { overflow: hidden; }
img { max-width: 100%; display: block; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
.shell { width: var(--shell); margin-inline: auto; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0;
  margin: -1px; overflow: hidden; clip: rect(0,0,0,0);
  white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 20px; top: -60px; z-index: 100;
  background: var(--ink); color: white; padding: 10px 14px;
}
.skip-link:focus { top: 20px; }

h1, h2, h3 {
  font-family: Fraunces, Georgia, serif;
  font-weight: 600;
  line-height: 1.08;
  margin: 0;
}
h1 { font-size: clamp(3rem, 7.2vw, 6.7rem); letter-spacing: -0.055em; max-width: 850px; }
h2 { font-size: clamp(2.2rem, 4.5vw, 4rem); letter-spacing: -0.035em; }
h3 { font-size: 1.45rem; }
p { margin-top: 0; }
.eyebrow {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.text-button, .text-link {
  border: 0;
  background: none;
  color: var(--accent-dark);
  cursor: pointer;
  font-weight: 600;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 4px;
}
.text-button.danger { color: #884b43; }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 19px;
  border: 1px solid var(--ink);
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
  text-decoration: none;
  transition: .2s ease;
}
.button.primary { background: var(--ink); color: white; }
.button.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.button.quiet { background: transparent; color: var(--ink); }
.button.quiet:hover { background: var(--surface); }
.button.full { width: 100%; }

/* ---------- Header ---------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(111, 103, 94, .18);
}
.header-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: Fraunces, Georgia, serif;
  font-size: 1.05rem;
  font-weight: 600;
  text-decoration: none;
}
.brand-mark { color: var(--accent); font-size: 1.6rem; }
.main-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative; /* anchor for dropdowns */
}

/* wp_nav_menu outputs <ul class="primary-menu"> — make it a flex row */
.primary-menu {
  display: flex;
  align-items: center;
  gap: 4px;
  list-style: none;
  margin: 0;
  padding: 0;
}

/* Top-level <li> */
.primary-menu > li {
  position: relative;
  display: flex;
  align-items: center;
}

/* Top-level links */
.primary-menu > li > a {
  display: inline-flex;
  align-items: center;
  font-size: .92rem;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
  transition: color .15s, background .15s;
  white-space: nowrap;
}
.primary-menu > li > a:hover,
.primary-menu > li.current-menu-item > a,
.primary-menu > li.current-menu-ancestor > a {
  color: var(--accent);
  background: var(--paper-deep);
}

/* Fallback: when theme outputs plain <a> directly in <nav> (no menu assigned) */
.main-nav > a {
  font-size: .92rem;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 6px;
  color: var(--ink);
}
.main-nav > a:hover { color: var(--accent); background: var(--paper-deep); }
.cart-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  padding: 8px 13px;
  cursor: pointer;
}
.cart-count {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  margin-left: 4px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: .75rem;
}
.menu-toggle { display: none; }

/* ---------- Hero ---------- */
.hero { padding: 100px 0 90px; }
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, .75fr);
  align-items: center;
  gap: 58px;
}
.hero-copy {
  max-width: 680px;
  margin: 28px 0 0;
  color: var(--muted);
  font-size: clamp(1.05rem, 1.8vw, 1.25rem);
}
.hero-actions { display: flex; gap: 12px; margin-top: 32px; flex-wrap: wrap; }
.hero-art {
  margin: 0;
  padding: 22px;
  background: var(--paper-deep);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.hero-art svg {
  width: 100%;
  stroke: var(--accent-dark);
  stroke-width: 2;
  fill: none;
}
.hero-art figcaption {
  border-top: 1px solid var(--line);
  padding-top: 14px;
  color: var(--muted);
  font-size: .8rem;
}

/* ---------- Sections ---------- */
.section { padding: 108px 0; border-top: 1px solid var(--line); }
.section-heading {
  display: grid;
  grid-template-columns: 1.4fr .6fr;
  gap: 60px;
  align-items: end;
  margin-bottom: 44px;
}
.section-heading > p,
.store-heading-actions p {
  max-width: 420px;
  margin: 0;
  color: var(--muted);
}
.work-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;
}
.work-card { min-width: 0; }
.work-image {
  position: relative;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid var(--line);
}
.work-image-one { background: #d9c2ab; }
.work-image-two { background: #b8b5a0; }
.work-image-three { background: #c8b5aa; }
.machine-form { position: absolute; inset: 15%; border: 2px solid var(--ink); }
.form-one { border-radius: 50% 50% 8px 8px; transform: rotate(-8deg); }
.form-two { border-radius: 50%; box-shadow: 42px 24px 0 -20px var(--olive), -46px 38px 0 -20px var(--accent); }
.form-three { border-radius: 4px; transform: rotate(45deg) scale(.7); }
.work-meta { padding-top: 18px; }
.work-year { color: var(--accent); font-size: .75rem; font-weight: 600; margin-bottom: 8px; }
.work-meta p:last-child { color: var(--muted); margin: 8px 0 0; }

/* ---------- Dictionary ---------- */
.dictionary-section { background: var(--paper-deep); }
.dictionary-tools {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 22px;
}
.search-field {
  min-height: 58px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.search-field svg { width: 20px; fill: none; stroke: var(--muted); stroke-width: 1.8; }
.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
}
.category-tabs { display: flex; gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.category-tabs button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}
.category-tabs button.active,
.category-tabs button:hover {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
.dictionary-layout {
  display: grid;
  grid-template-columns: minmax(260px, .42fr) minmax(0, 1fr);
  min-height: 600px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.dictionary-index { border-right: 1px solid var(--line); }
.index-meta {
  height: 54px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  font-size: .82rem;
}
.dictionary-list { max-height: 650px; overflow: auto; }
.word-button {
  width: 100%;
  border: 0;
  border-bottom: 1px solid rgba(216, 205, 191, .72);
  background: transparent;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
}
.word-button:hover,
.word-button.active { background: var(--paper); }
.word-button code {
  font: 500 1rem DM Mono, monospace;
  color: var(--accent-dark);
}
.word-button span { display: block; color: var(--muted); font-size: .77rem; margin-top: 3px; }
.dictionary-detail { padding: clamp(28px, 5vw, 58px); }
.empty-state { max-width: 560px; margin-top: 90px; }
.empty-state p:last-child { color: var(--muted); margin-top: 12px; }
.word-topline {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: start;
  margin-bottom: 28px;
}
.word-title code {
  display: block;
  font: 500 clamp(2rem, 5vw, 4rem) DM Mono, monospace;
  color: var(--accent-dark);
  letter-spacing: -.05em;
}
.word-stack {
  margin-top: 9px;
  font: 400 .9rem DM Mono, monospace;
  color: var(--muted);
}
.category-badge {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 11px;
  color: var(--muted);
  font-size: .74rem;
}
.definition { font-size: 1.1rem; max-width: 760px; }
.detail-block { margin-top: 34px; }
.detail-block h4 {
  margin: 0 0 10px;
  font-size: .75rem;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--accent);
}
.code-block {
  position: relative;
  background: #2c2925;
  color: #f6efe5;
  border-radius: 12px;
  padding: 20px;
  overflow: auto;
}
.code-block pre {
  margin: 0;
  white-space: pre-wrap;
  font: 400 .92rem/1.7 DM Mono, monospace;
}
.copy-code {
  position: absolute;
  right: 10px;
  top: 10px;
  border: 1px solid rgba(255,255,255,.22);
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: white;
  padding: 5px 9px;
  cursor: pointer;
  font-size: .72rem;
}
.related-words { display: flex; gap: 8px; flex-wrap: wrap; }
.related-words button {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 7px 10px;
  cursor: pointer;
  font-family: DM Mono, monospace;
}

/* ---------- Store ---------- */
.store-heading-actions { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; }
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 24px;
}
.product-card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}
.product-image {
  aspect-ratio: 4/3;
  display: grid;
  place-items: center;
  background: var(--paper-deep);
  overflow: hidden;
}
.product-image img { width: 100%; height: 100%; object-fit: cover; }
.product-placeholder {
  width: 40%;
  aspect-ratio: 1;
  border: 2px solid var(--accent);
  border-radius: 50% 50% 12% 12%;
  transform: rotate(-7deg);
}
.product-content { padding: 20px; display: flex; flex: 1; flex-direction: column; }
.product-category {
  color: var(--accent);
  font-size: .72rem;
  letter-spacing: .12em;
  text-transform: uppercase;
  font-weight: 600;
  margin-bottom: 8px;
}
.product-content p { color: var(--muted); }
.product-footer {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.product-price { font-weight: 600; }
.inquire-price { color: var(--muted); font-size: .85rem; font-style: italic; }
.sold-label { color: var(--muted); font-weight: 600; }

/* ---------- About / footer ---------- */
.about-section { background: var(--accent-soft); }
.about-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 80px; }
.about-copy { max-width: 600px; }
.about-copy p { font-size: 1.08rem; }
.footer-inner {
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: .85rem;
}
.footer-inner p { margin: 0; }
.footer-inner div { display: flex; gap: 18px; }
.footer-inner a { text-decoration: none; }

/* ---------- Modal, forms, cart ---------- */
.modal {
  width: min(980px, calc(100% - 30px));
  max-height: min(90vh, 900px);
  padding: 0;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
}
.modal::backdrop { background: rgba(30, 25, 21, .58); backdrop-filter: blur(3px); }
.modal-card {
  max-height: 90vh;
  overflow: auto;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.cart-card { width: min(560px, 100%); margin-left: auto; padding: 28px; }
.manager-card { padding: 30px; }
.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.icon-button {
  width: 40px; height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  font-size: 1.6rem;
  line-height: 1;
}
.cart-items { padding: 12px 0; }
.cart-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 16px 0;
  border-bottom: 1px solid var(--line);
}
.cart-item p { color: var(--muted); margin: 4px 0 0; font-size: .83rem; }
.cart-item button {
  border: 0; background: none; color: var(--accent); cursor: pointer;
}
.cart-empty { padding: 40px 0; color: var(--muted); text-align: center; }
.cart-summary { padding-top: 20px; }
.cart-summary > div {
  display: flex; justify-content: space-between;
  margin-bottom: 18px; font-size: 1.1rem;
}
.fine-print { color: var(--muted); font-size: .72rem; margin: 10px 0 0; text-align: center; }
.manager-layout { display: grid; grid-template-columns: .8fr 1.2fr; gap: 36px; padding-top: 24px; }
.product-form { display: grid; gap: 14px; }
.product-form label {
  display: grid; gap: 6px; color: var(--muted); font-size: .82rem;
}
.product-form input,
.product-form textarea,
.product-form select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  padding: 10px 11px;
  color: var(--ink);
}
.form-row { display: grid; grid-template-columns: 1fr 110px; gap: 12px; }
.product-form .check-label { display: flex; align-items: center; gap: 9px; }
.product-form .check-label input { width: auto; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; padding-top: 6px; }
.manager-list-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; }
.manager-product-list { margin-top: 10px; }
.manager-product {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.manager-product p { color: var(--muted); font-size: .8rem; margin: 4px 0 0; }
.manager-actions { display: flex; gap: 7px; align-items: center; }
.manager-actions button {
  border: 1px solid var(--line);
  background: transparent;
  border-radius: 999px;
  padding: 6px 9px;
  cursor: pointer;
  font-size: .76rem;
}
.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 100;
  max-width: 320px;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  opacity: 0;
  transform: translateY(12px);
  pointer-events: none;
  transition: .2s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 900px) {
  .hero-grid, .section-heading, .about-grid { grid-template-columns: 1fr; }
  .hero-art { max-width: 560px; }
  .work-grid, .product-grid { grid-template-columns: repeat(2, 1fr); }
  .dictionary-tools { grid-template-columns: 1fr; }
  .category-tabs { justify-content: flex-start; }
  .manager-layout { grid-template-columns: 1fr; }
}
@media (max-width: 720px) {
  :root { --shell: min(100% - 28px, 1180px); }
  .header-inner { min-height: 68px; }
  .menu-toggle {
    width: 42px; height: 42px;
    display: grid; place-content: center; gap: 6px;
    border: 1px solid var(--line); border-radius: 50%; background: transparent;
  }
  .menu-toggle span:not(.sr-only) { display: block; width: 18px; height: 1px; background: var(--ink); }
  .main-nav {
    position: absolute;
    top: 68px; left: 0; right: 0;
    display: none;
    align-items: stretch;
    flex-direction: column;
    gap: 0;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
    padding: 14px;
  }
  .main-nav.open { display: flex; }

  /* primary-menu ul stacks vertically inside the mobile drawer */
  .main-nav .primary-menu {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
  }
  .main-nav .primary-menu > li {
    flex-wrap: wrap;
  }
  .main-nav .primary-menu > li > a {
    flex: 1;
    padding: 12px;
    border-radius: 0;
  }

  /* cart button and plain fallback links */
  .main-nav > a, .cart-button { padding: 12px; text-align: left; }
  .hero { padding: 70px 0; }
  .section { padding: 78px 0; }
  .work-grid, .product-grid { grid-template-columns: 1fr; }
  .dictionary-layout { grid-template-columns: 1fr; }
  .dictionary-index { border-right: 0; border-bottom: 1px solid var(--line); }
  .dictionary-list { max-height: 300px; }
  .dictionary-detail { min-height: 440px; }
  .empty-state { margin-top: 40px; }
  .footer-inner { align-items: flex-start; flex-direction: column; justify-content: center; gap: 14px; }
  .footer-inner div { flex-wrap: wrap; }
  .manager-card, .cart-card { padding: 20px; }
}

/* ── Dropdown / submenu navigation ─────────────────────────────────── */

/* Each top-level <li> is already position:relative (set in .primary-menu > li above).
   Nothing extra needed here — the sub-menu panel uses that as its anchor. */

/* Chevron toggle button */
.submenu-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  margin-left: 1px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: .85rem;
  line-height: 1;
  transition: background .18s, color .18s, transform .22s;
  flex-shrink: 0;
}
.submenu-toggle:hover {
  background: var(--paper-deep);
  color: var(--ink);
}
.menu-item-has-children.is-open > .submenu-toggle {
  transform: rotate(180deg);
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}

/* ── Submenu panel ─────────────────────────────────────────────────── */
.primary-menu .sub-menu {
  /* hidden by default */
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  /* positioning — anchored to the parent <li> */
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 6px;
  z-index: 1000;
  /* size */
  min-width: 200px;
  /* reset list styles */
  list-style: none;
  margin-left: 0;
  padding: 6px 0;
  /* visual */
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(64,46,35,.14);
  /* animation */
  transform: translateY(-4px);
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear .18s;
}

/* Visible/open state */
.menu-item-has-children.is-open > .sub-menu {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  transition: opacity .18s ease, transform .18s ease, visibility 0s linear 0s;
}

/* Sub-menu items */
.primary-menu .sub-menu li {
  position: relative;
  list-style: none;
}
.primary-menu .sub-menu a {
  display: flex;
  align-items: center;
  padding: 9px 16px;
  font-size: .88rem;
  font-weight: 400;
  color: var(--ink);
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s, color .12s;
  gap: 8px;
}
.primary-menu .sub-menu a:hover {
  background: var(--paper);
  color: var(--accent);
}
.primary-menu .sub-menu .current-menu-item > a,
.primary-menu .sub-menu .current-menu-ancestor > a {
  color: var(--accent);
  font-weight: 600;
}
.primary-menu .sub-menu li + li {
  border-top: 1px solid rgba(216,205,191,.5);
}

/* ── Third-level flyout ────────────────────────────────────────────── */
.primary-menu .sub-menu .sub-menu {
  top: -6px;
  left: 100%;
  margin-left: 4px;
  margin-top: 0;
}
.primary-menu .sub-menu .submenu-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  font-size: .72rem;
}
.primary-menu .sub-menu .menu-item-has-children.is-open > .submenu-toggle {
  transform: translateY(-50%) rotate(90deg);
}

/* ── Mobile accordion ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  .primary-menu .sub-menu {
    /* Override absolute → static for accordion behaviour */
    position: static !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
    box-shadow: none;
    border: none;
    border-top: 1px solid var(--line);
    border-radius: 0;
    padding: 0;
    margin: 0;
    transform: none !important;
    /* Accordion: collapsed by default */
    max-height: 0;
    overflow: hidden;
    transition: max-height .28s ease;
    background: var(--paper-deep);
    /* Take full width of the parent <li> */
    flex-basis: 100%;
    width: 100%;
  }
  .menu-item-has-children.is-open > .sub-menu {
    max-height: 800px;
    transition: max-height .35s ease;
  }
  .primary-menu .sub-menu a {
    padding: 11px 24px;
  }
  /* Third-level on mobile */
  .primary-menu .sub-menu .sub-menu {
    left: 0;
    background: var(--paper);
  }
  .primary-menu .sub-menu .sub-menu a {
    padding-left: 40px;
  }
  .primary-menu .sub-menu .submenu-toggle {
    position: static;
    transform: none;
    top: auto; right: auto;
  }
  .menu-item-has-children.is-open > .submenu-toggle {
    transform: rotate(180deg);
  }
}
