/* === Flastomari — Renecs en Català === */

:root {
  --bg: #0a0a0a;
  --text: #f5f0e8;
  --text-muted: #a09a8e;
  --accent: #c4553a;
  --tag-bg: rgba(196, 85, 58, 0.15);
  --tag-border: rgba(196, 85, 58, 0.4);
  --btn-hover: rgba(245, 240, 232, 0.08);
  --transition: 0.4s ease;
}

[data-theme="light"] {
  --bg: #f5f0e8;
  --text: #0a0a0a;
  --text-muted: #5c564a;
  --accent: #a03820;
  --tag-bg: rgba(160, 56, 32, 0.1);
  --tag-border: rgba(160, 56, 32, 0.3);
  --btn-hover: rgba(10, 10, 10, 0.06);
}

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

html {
  font-size: 16px;
  overflow: -moz-scrollbars-none;
  scrollbar-width: none;
}

html::-webkit-scrollbar {
  display: none;
}

body {
  font-family: Georgia, "Times New Roman", serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem 2rem 5.5rem;
  transition: background var(--transition), color var(--transition);
}

/* Brand */
.brand {
  position: fixed;
  top: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
}

.brand-name {
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  cursor: default;
  transition: color var(--transition);
}

.brand-name:hover {
  color: var(--text);
}

.brand-tooltip {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.5rem;
  white-space: nowrap;
  font-size: 0.7rem;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--tag-border);
  border-radius: 0.4rem;
  padding: 0.35em 0.8em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.brand:hover .brand-tooltip {
  opacity: 1;
}

/* Top-right controls */
.controls {
  position: fixed;
  top: 1.5rem;
  right: 1.5rem;
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.ctrl-btn {
  background: none;
  border: 1px solid var(--text-muted);
  border-radius: 0.45rem;
  width: 2.1rem;
  height: 2.1rem;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color var(--transition), color var(--transition);
}

.ctrl-btn svg {
  width: 0.95rem;
  height: 0.95rem;
  stroke-width: 1.5;
}

.ctrl-btn:hover {
  border-color: var(--text);
  color: var(--text);
}

.ctrl-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Custom tooltips */
[data-tooltip] {
  position: relative;
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 0.5rem;
  white-space: nowrap;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.7rem;
  font-weight: normal;
  font-style: normal;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-muted);
  background: var(--bg);
  border: 1px solid var(--tag-border);
  border-radius: 0.4rem;
  padding: 0.35em 0.8em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
  z-index: 30;
}

[data-tooltip]:hover::after {
  opacity: 1;
}

.ctrl-btn.safe-on {
  border-color: var(--accent);
  color: var(--accent);
}

.ctrl-btn.shared {
  border-color: var(--text);
  color: var(--text);
}

.ctrl-lang {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.6rem;
  font-weight: bold;
  letter-spacing: 0.05em;
}

/* Menu toggle — hidden on desktop */
.menu-toggle {
  display: none;
}

/* Menu panel — inline on desktop */
.menu-panel {
  display: contents;
}

/* About overlay */
.about-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  animation: fadeOverlay 0.3s ease;
}

.about-overlay[hidden] {
  display: none;
}

@keyframes fadeOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}

.about-box {
  background: var(--bg);
  border: 1px solid var(--tag-border);
  border-radius: 0.8rem;
  max-width: 36rem;
  max-height: 80vh;
  overflow-y: auto;
  scrollbar-width: none;
  padding: 2.5rem;
  position: relative;
  color: var(--text);
  line-height: 1.7;
}

.about-box::-webkit-scrollbar {
  display: none;
}

.about-box h2 {
  font-size: 1.4rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.about-subtitle {
  font-style: italic;
  color: var(--text-muted);
  margin-bottom: 2rem;
  font-size: 0.9rem;
}

.about-box h3 {
  font-size: 0.85rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-top: 1.8rem;
  margin-bottom: 0.6rem;
}

.about-box p {
  font-size: 0.88rem;
  color: var(--text-muted);
  margin-bottom: 0.8rem;
}

.about-box ul {
  list-style: none;
  padding: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.about-box ul li {
  padding: 0.2em 0;
}

.about-box ul li strong {
  color: var(--text);
  font-weight: normal;
}

.about-box em {
  font-style: italic;
}

/* Lightning tip */
.about-ln {
  margin-top: 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
}

.about-qr {
  background: #fff;
  border-radius: 0.4rem;
  padding: 0.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 132px;
  min-width: 132px;
}

.about-ln-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.about-ln-address {
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.7;
  word-break: break-all;
}

.about-ln-copy {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.65rem;
  color: var(--accent);
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: 0.35rem;
  padding: 0.3em 0.6em;
  cursor: pointer;
  transition: border-color 0.2s ease;
}

.about-ln-copy:hover {
  border-color: var(--accent);
}

.about-ln-copy.copied {
  color: var(--text);
  border-color: var(--text);
}

.about-sep {
  margin: 0 0.3em;
  opacity: 0.4;
}

.about-footer {
  margin-top: 2rem;
  font-size: 0.78rem;
  opacity: 0.6;
}

.about-link {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid var(--tag-border);
  transition: border-color 0.2s ease;
}

.about-link:hover {
  border-color: var(--accent);
}

.about-close {
  position: absolute;
  top: 1rem;
  right: 1.2rem;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  padding: 0.2rem 0.5rem;
  line-height: 1;
  transition: color 0.2s ease;
}

.about-close:hover {
  color: var(--text);
}

.about-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.about-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Search bar */
.search-bar {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg);
  border: 1px solid var(--text-muted);
  border-radius: 0.45rem;
  padding: 0.3rem 0.5rem;
  overflow: hidden;
  width: 16rem;
  animation: searchExpand 0.25s ease;
  transform-origin: top right;
}

@keyframes searchExpand {
  from { width: 2.1rem; opacity: 0; transform: scaleY(0.8); }
  to   { width: 16rem;  opacity: 1; transform: scaleY(1); }
}

.search-bar[hidden] {
  display: none;
}

.search-input {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.85rem;
  color: var(--text);
  background: none;
  border: none;
  outline: none;
  flex: 1;
  min-width: 0;
  letter-spacing: 0.02em;
}

.search-input::placeholder {
  color: var(--text-muted);
  opacity: 0.5;
}

.search-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.15rem;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.search-close:hover {
  color: var(--text);
}

.search-close:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.about-ln-copy:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.search-input:focus-visible {
  outline: none;
}

.search-close svg {
  width: 0.85rem;
  height: 0.85rem;
  stroke-width: 1.5;
}

/* Counter */
.counter {
  position: fixed;
  top: 1.7rem;
  left: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  transition: color var(--transition);
}

.counter-label {
  font-size: 0.65rem;
  font-style: italic;
  opacity: 0.7;
  margin-left: 0.3em;
}

/* Main card */
.card {
  max-width: 44rem;
  width: 100%;
  text-align: center;
  animation: fadeIn 0.5s ease;
}

.pills {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.pill {
  display: inline-block;
  font-size: 0.65rem;
  font-style: italic;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.35em 0.7em;
  border-radius: 0.35rem;
  transition: color var(--transition), border-color var(--transition), background var(--transition);
}

.pill-cat {
  color: var(--accent);
  border: 1px solid var(--tag-border);
  background: var(--tag-bg);
}

.pill-haddock {
  color: var(--text-muted);
  border: 1px solid var(--text-muted);
  background: none;
  opacity: 0.6;
  font-style: normal;
}

.pill-dialect {
  color: var(--text-muted);
  border: 1px solid transparent;
  background: none;
  opacity: 0.5;
  font-style: normal;
}

.paraula {
  font-size: clamp(3.5rem, 11vw, 7rem);
  font-weight: normal;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 1.5rem;
}

.definicio {
  font-size: 1.45rem;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 36rem;
  margin: 0 auto 1rem;
  transition: color var(--transition);
}

.exemple {
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.5;
  color: var(--text-muted);
  max-width: 34rem;
  margin: 0 auto 1.5rem;
  transition: color var(--transition);
}

.exemple::before {
  content: "\201C";
}

.exemple::after {
  content: "\201D";
}

.origen {
  font-size: 0.88rem;
  color: var(--text-muted);
  opacity: 0.65;
  max-width: 34rem;
  margin: 0 auto;
  line-height: 1.5;
  transition: color var(--transition);
}

.album {
  font-size: 0.78rem;
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.45;
  max-width: 34rem;
  margin: 0.5rem auto 0;
  line-height: 1.4;
  transition: color var(--transition);
}

/* Nav buttons (prev/next) */
.prev, .next {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.8rem;
  padding: 0.6rem 0.8rem;
  border-radius: 0.5rem;
  transition: color var(--transition), background 0.2s ease, opacity 0.3s ease;
  letter-spacing: 0.2em;
}

.next { right: 1.5rem; }
.prev { left: 1.5rem; }

.prev[hidden] { display: none; }

.prev svg, .next svg {
  width: 1.8rem;
  height: 1.8rem;
  stroke-width: 1.5;
}

.prev:hover, .next:hover {
  color: var(--text);
  background: var(--btn-hover);
}

.prev:focus-visible, .next:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.prev[data-tooltip]::after, .next[data-tooltip]::after {
  display: none;
}

/* Footer */
.footer {
  position: fixed;
  bottom: 1.2rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.4;
  letter-spacing: 0.05em;
  transition: color var(--transition);
}

/* Filters */
.filters-wrap {
  position: fixed;
  bottom: 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 0 1.5rem;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem;
}

.filter-sep {
  width: 1px;
  height: 1em;
  background: var(--text-muted);
  opacity: 0.2;
  align-self: center;
  margin: 0 0.15rem;
}

.filter-btn {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.65rem;
  font-style: italic;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--tag-bg);
  border: 1px solid var(--tag-border);
  border-radius: 0.35rem;
  padding: 0.35em 0.6em;
  cursor: pointer;
  transition: opacity var(--transition), border-color var(--transition),
    color var(--transition), background var(--transition);
}

.filter-btn:hover {
  border-color: var(--accent);
}

.filter-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.filter-btn.off {
  opacity: 0.25;
  text-decoration: line-through;
}

.filter-btn.filter-origin {
  font-style: normal;
  color: var(--text-muted);
  background: none;
  border-color: var(--text-muted);
  opacity: 0.55;
}

.filter-btn.filter-origin:hover {
  opacity: 0.85;
  border-color: var(--text);
}

.filter-btn.filter-origin.on {
  opacity: 1;
  color: var(--text);
  border-color: var(--text);
}

.filter-btn.filter-origin.off {
  opacity: 0.25;
  text-decoration: none;
}

/* Fade animation */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card.fade-out {
  opacity: 0;
  transform: translateY(-6px) scale(0.99);
}

/* Keyboard hint */
.hint {
  position: fixed;
  bottom: 4.8rem;
  font-size: 0.7rem;
  color: var(--text-muted);
  opacity: 0.35;
  transition: color var(--transition);
}

kbd {
  font-family: Georgia, serif;
  font-size: 0.65rem;
  border: 1px solid var(--text-muted);
  border-radius: 3px;
  padding: 0.1em 0.4em;
  opacity: 0.7;
}

/* Mobile */
@media (max-width: 600px) {
  body {
    padding: 3rem 1.5rem 7.5rem;
    align-items: center;
  }

  .card {
    max-width: 100%;
  }

  /* Brand + counter header */
  .brand {
    top: 1rem;
  }

  .counter {
    top: 1.15rem;
    left: 1rem;
    font-size: 0.7rem;
  }

  /* Menu toggle visible */
  .menu-toggle {
    display: flex;
  }

  /* Controls: just the menu button top-right */
  .controls {
    position: fixed;
    top: 0.85rem;
    right: 1rem;
    gap: 0;
    z-index: 20;
    flex-direction: column;
    align-items: flex-end;
  }

  /* Hide panel buttons by default */
  .menu-panel {
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    margin-top: 0.5rem;
    padding: 0.5rem 0.6rem;
    background: var(--bg);
    border: 1px solid var(--tag-border);
    border-radius: 0.45rem;
    animation: menuSlide 0.2s ease;
  }

  @keyframes menuSlide {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  .controls.menu-open .menu-panel {
    display: flex;
  }

  /* Each menu button becomes a row: icon + label */
  .menu-panel .ctrl-btn {
    width: auto;
    height: auto;
    border: none;
    border-radius: 0.35rem;
    padding: 0.45rem 0.6rem;
    gap: 0.5rem;
    justify-content: flex-start;
    font-size: 0.8rem;
  }

  .menu-panel .ctrl-btn:hover {
    background: var(--btn-hover);
  }

  .menu-panel .ctrl-btn svg {
    width: 0.85rem;
    height: 0.85rem;
    flex-shrink: 0;
  }

  .menu-panel .ctrl-btn::after {
    content: attr(data-label);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 0.78rem;
    font-weight: normal;
    letter-spacing: 0;
    white-space: nowrap;
  }

  .menu-panel .ctrl-lang::after {
    content: attr(data-label);
  }

  .menu-panel .ctrl-btn.safe-on {
    border: none;
  }

  .menu-toggle {
    width: 2.1rem;
    height: 2.1rem;
  }

  .menu-toggle svg {
    width: 1rem;
    height: 1rem;
  }

  /* Content typography */
  .paraula {
    font-size: clamp(2.2rem, 10vw, 4rem);
  }

  .definicio {
    font-size: 1.05rem;
  }

  .exemple {
    font-size: 0.95rem;
  }

  .origen {
    font-size: 0.8rem;
  }

  .album {
    font-size: 0.7rem;
  }

  /* Nav buttons — very bottom */
  .prev, .next {
    position: fixed;
    top: auto;
    bottom: 0.8rem;
    transform: none;
    padding: 0.5rem 0.8rem;
    border: 1px solid var(--text-muted);
    border-radius: 0.45rem;
    transition: color var(--transition), background 0.2s ease, border-color var(--transition);
  }

  .prev:hover, .next:hover {
    border-color: var(--text);
  }

  .prev { left: calc(50% - 2.8rem); }
  .next { right: calc(50% - 2.8rem); }

  .prev svg, .next svg {
    width: 1.1rem;
    height: 1.1rem;
  }

  /* Search bar */
  .search-bar {
    position: fixed;
    top: 3.5rem;
    right: 1rem;
    left: 1rem;
    width: auto;
    z-index: 25;
  }

  @keyframes searchExpand {
    from { opacity: 0; transform: scaleY(0.8); }
    to   { opacity: 1; transform: scaleY(1); }
  }

  .search-input {
    font-size: 0.8rem;
  }

  /* Brand tooltip */
  .brand-tooltip {
    white-space: normal;
    width: max-content;
    max-width: 80vw;
    text-align: center;
  }

  /* No hover tooltips on mobile (but allow menu labels) */
  [data-tooltip]::after {
    display: none;
  }

  .menu-panel .ctrl-btn::after {
    display: inline;
    position: static;
    margin: 0;
    border: none;
    background: none;
    padding: 0;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    content: attr(data-label);
  }

  .hint {
    display: none;
  }

  /* Filters — above nav buttons */
  .filters-wrap {
    bottom: 4rem;
    padding: 0 0.8rem;
  }

  .filter-btn {
    font-size: 0.58rem;
    padding: 0.3em 0.5em;
  }
}

/* Very small screens */
@media (max-width: 380px) {
  .brand-name {
    font-size: 0.75rem;
  }

  .paraula {
    font-size: clamp(1.8rem, 9vw, 3.2rem);
  }

  .definicio {
    font-size: 0.95rem;
  }

  .pills {
    gap: 0.3rem;
    margin-bottom: 1rem;
  }

  .pill {
    font-size: 0.55rem;
  }

  .filter-btn {
    font-size: 0.52rem;
    padding: 0.25em 0.4em;
  }

  .filter-row {
    gap: 0.25rem;
  }

  .filters-wrap {
    bottom: 4rem;
  }

  .prev { left: calc(50% - 2.2rem); }
  .next { right: calc(50% - 2.2rem); }
}
