/* ============================================================
   Taberna do Dragão Dourado
   Menu de aventureiro estilo RPG · pergaminho, madeira, raridades
   Nested CSS
   ============================================================ */

:root {
  --wood:   #1b1712;   /* madeira escura (fundo) */
  --wood2:  #241d15;
  --parch:  #e7d6ac;   /* pergaminho */
  --parch2: #dcc796;
  --ink:    #2e2110;   /* tinta */
  --gold:   #e2b23c;
  --gold-dk:#a9791f;

  /* raridades */
  --common: #9aa0a6;
  --rare:   #4a90d9;
  --epic:   #b063d6;
  --legend: #ef9d2b;

  --font-title: "Cinzel", serif;
  --font-body:  "MedievalSharp", "Cinzel", serif;
  --font-pixel: "Press Start 2P", monospace;

  --maxw: 1120px;
  --ease: cubic-bezier(0.34, 1.3, 0.64, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--parch);
  background: var(--wood);
  line-height: 1.6;
  overflow-x: hidden;
  /* torch-lit stone/wood glow */
  background-image:
    radial-gradient(120% 80% at 50% -10%, rgba(226,178,60,0.14), transparent 55%),
    radial-gradient(80% 60% at 50% 110%, rgba(226,178,60,0.08), transparent 55%);

  &.is-loading { overflow: hidden; }
}

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

h1, h2, h3 { margin: 0; line-height: 1.1; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
::selection { background: var(--gold); color: var(--wood); }

/* ---------- Reveal ---------- */
.reveal {
  opacity: 0;
  transform: translateY(30px) scale(0.96);
  transition: opacity 0.6s var(--ease), transform 0.6s var(--ease);
  &.is-visible { opacity: 1; transform: none; }
}

/* ============================================================
   Intro — a sealed scroll unfurls
   ============================================================ */
.intro {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 40%, #2a2216, var(--wood));
  transition: opacity 0.6s ease, visibility 0.6s;

  &.is-done { opacity: 0; visibility: hidden; }

  & .intro__scroll {
    text-align: center;
    padding: 2.4rem 2rem;
    background: linear-gradient(180deg, var(--parch), var(--parch2));
    border: 3px solid var(--gold-dk);
    border-radius: 6px;
    box-shadow: 0 0 60px rgba(226,178,60,0.3), inset 0 0 30px rgba(169,121,31,0.3);
    color: var(--ink);
    transform: scaleY(0.02);
    transform-origin: center;
    animation: unfurl 0.9s var(--ease) 0.2s forwards;
  }
  & .intro__seal {
    font-size: 3rem;
    display: block;
    opacity: 0;
    animation: sealPop 0.5s var(--ease) 1s forwards;
  }
  & .intro__title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(1.6rem, 6vw, 2.6rem);
    margin: 0.4rem 0 0;
    opacity: 0;
    animation: fade 0.6s ease 1.15s forwards;
  }
  & .intro__load {
    font-family: var(--font-body);
    font-size: 1rem;
    color: var(--gold-dk);
    margin: 0.6rem 0 0;
    opacity: 0;
    animation: fade 0.6s ease 1.35s forwards;
  }
}
@keyframes unfurl { to { transform: scaleY(1); } }
@keyframes sealPop { from { opacity: 0; transform: scale(0.4) rotate(-20deg); } to { opacity: 1; transform: none; } }
@keyframes fade { to { opacity: 1; } }

/* ============================================================
   HUD / header
   ============================================================ */
.hud {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 2px solid transparent;
  transition: background 0.4s ease, border-color 0.4s, padding 0.4s;

  &.is-scrolled {
    background: rgba(27,23,18,0.92);
    border-bottom-color: var(--gold-dk);
    padding-block: 0.55rem;
  }

  & .crest {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.1rem;
    letter-spacing: 0.05em;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(226,178,60,0.4);
  }

  & .quests {
    display: flex;
    gap: clamp(0.7rem, 2.5vw, 1.6rem);
    & a {
      font-family: var(--font-body);
      font-size: 1rem;
      color: var(--parch);
      opacity: 0.8;
      transition: color 0.3s, opacity 0.3s;
      &:hover { color: var(--gold); opacity: 1; }
    }
  }

  & .purse {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.8rem;
    border: 1px solid var(--gold-dk);
    border-radius: 999px;
    background: rgba(226,178,60,0.08);
    & .purse__val { font-family: var(--font-pixel); font-size: 0.7rem; color: var(--gold); }
  }
}

/* ============================================================
   Hero
   ============================================================ */
.hero {
  max-width: var(--maxw);
  margin-inline: auto;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  padding: 8rem clamp(1.4rem, 6vw, 3rem) 5rem;

  & .hero__over {
    font-family: var(--font-body);
    font-size: 1.1rem;
    color: var(--gold);
    letter-spacing: 0.1em;
    margin: 0 0 0.8rem;
  }
  & .hero__title {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: clamp(2.6rem, 10vw, 6rem);
    color: var(--parch);
    text-shadow: 0 4px 0 rgba(0,0,0,0.4);
    & span { color: var(--gold); text-shadow: 0 0 24px rgba(226,178,60,0.5); }
  }
  & .hero__lede {
    max-width: 34rem;
    margin: 1.6rem auto 1.8rem;
    color: #d8c9a4;
    font-size: 1.1rem;
    & b { color: var(--gold); font-weight: 400; }
  }
  & .hero__legend {
    display: flex;
    gap: 0.6rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 2rem;
  }
}

/* rarity chips */
.chip {
  font-family: var(--font-pixel);
  font-size: 0.55rem;
  padding: 0.4rem 0.7rem;
  border-radius: 4px;
  border: 1px solid currentColor;
  text-transform: uppercase;
}
.chip--common { color: var(--common); }
.chip--rare   { color: var(--rare); }
.chip--epic   { color: var(--epic); }
.chip--legend { color: var(--legend); }

/* ---------- Button ---------- */
.btn {
  align-self: center;
  display: inline-block;
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: 0.05em;
  color: var(--wood);
  background: linear-gradient(180deg, var(--gold), var(--gold-dk));
  padding: 0.9rem 2.2rem;
  border-radius: 6px;
  border: 2px solid #f2d27a;
  box-shadow: 0 5px 0 #6f4e14, 0 0 24px rgba(226,178,60,0.4);
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
  &:hover { transform: translateY(-3px); box-shadow: 0 9px 0 #6f4e14, 0 0 34px rgba(226,178,60,0.6); }
  &:active { transform: translateY(2px); box-shadow: 0 2px 0 #6f4e14; }
}

/* ============================================================
   Bags (menu sections)
   ============================================================ */
.bag {
  padding: clamp(3.5rem, 8vw, 6rem) clamp(1.2rem, 5vw, 2.5rem);
  & > * { max-width: var(--maxw); margin-inline: auto; }

  &--alt { background: rgba(226,178,60,0.04); }

  & .bag__head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    justify-content: center;
    margin-bottom: 2.4rem;

    & .bag__ico { font-size: 1.8rem; }
    & .bag__title {
      font-family: var(--font-title);
      font-weight: 700;
      font-size: clamp(1.6rem, 5vw, 2.8rem);
      color: var(--gold);
      text-align: center;
    }
    &::before, &::after {
      content: "";
      flex: 1;
      max-width: 90px;
      height: 1px;
      background: linear-gradient(90deg, transparent, var(--gold-dk));
    }
    &::after { background: linear-gradient(90deg, var(--gold-dk), transparent); }
  }
}

/* ---------- Item cards (inventory) ---------- */
.items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.3rem;
}

.item {
  --rarity: var(--common);
  position: relative;
  background: linear-gradient(180deg, var(--parch), var(--parch2));
  color: var(--ink);
  border: 2px solid var(--rarity);
  border-radius: 8px;
  padding: 1.5rem 1.3rem 1.3rem;
  text-align: center;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 10px 24px -14px #000, 0 0 16px -6px var(--rarity);
  transition: transform 0.25s var(--ease), box-shadow 0.25s var(--ease);
  cursor: pointer;

  & .item__emoji {
    font-size: 2.6rem;
    display: inline-block;
    filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
    transition: transform 0.3s var(--ease);
  }
  & .item__rank {
    display: block;
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--rarity);
    filter: brightness(0.7);
    margin: 0.5rem 0 0.2rem;
  }
  & .item__name {
    font-family: var(--font-title);
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--ink);
  }
  & .item__lore {
    font-family: var(--font-body);
    font-size: 0.9rem;
    color: #5a4526;
    margin: 0.4rem 0 0.7rem;
    min-height: 3.4em;
  }
  & .item__buff {
    font-family: var(--font-pixel);
    font-size: 0.5rem;
    line-height: 1.7;
    color: #2f6b3a;
    background: rgba(47,107,58,0.1);
    border-radius: 4px;
    padding: 0.4rem;
    margin: 0 0 0.8rem;
  }
  & .item__cost {
    display: inline-block;
    font-family: var(--font-pixel);
    font-size: 0.62rem;
    color: var(--gold-dk);
    background: rgba(169,121,31,0.14);
    border: 1px solid var(--gold-dk);
    border-radius: 4px;
    padding: 0.4rem 0.7rem;
  }

  &:hover {
    transform: translateY(-6px);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2), 0 18px 30px -14px #000, 0 0 28px -2px var(--rarity);
  }
  &:hover .item__emoji { transform: scale(1.18) rotate(-6deg); }

  /* per-rarity colour binding */
  &--common { --rarity: var(--common); }
  &--rare   { --rarity: var(--rare); }
  &--epic   { --rarity: var(--epic); }
  &--legend {
    --rarity: var(--legend);
    /* legendary shimmer */
    &::before {
      content: "";
      position: absolute;
      inset: -2px;
      border-radius: 8px;
      padding: 2px;
      background: linear-gradient(120deg, transparent 20%, rgba(255,220,140,0.9), transparent 80%);
      background-size: 220% 100%;
      -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
      -webkit-mask-composite: xor;
      mask-composite: exclude;
      animation: shimmer 2.6s linear infinite;
      pointer-events: none;
    }
  }
}
@keyframes shimmer { from { background-position: 220% 0; } to { background-position: -120% 0; } }

/* little "+coin" popup when clicking an item */
.coinpop {
  position: fixed;
  z-index: 200;
  font-family: var(--font-pixel);
  font-size: 0.7rem;
  color: var(--gold);
  text-shadow: 0 2px 4px #000;
  pointer-events: none;
  animation: floatUp 0.9s var(--ease) forwards;
}
@keyframes floatUp {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-40px); }
}

/* ============================================================
   Footer
   ============================================================ */
.foot {
  text-align: center;
  padding: clamp(3rem, 6vw, 4.5rem) 1.5rem 3.5rem;
  border-top: 2px solid var(--gold-dk);

  & .foot__mark { font-family: var(--font-title); font-weight: 700; font-size: 1.4rem; color: var(--gold); margin: 0 0 0.5rem; }
  & .foot__tag { font-family: var(--font-body); color: #d8c9a4; margin: 0; }
  & .foot__note { margin-top: 1.2rem; font-family: var(--font-pixel); font-size: 0.55rem; line-height: 1.8; color: var(--gold-dk); }
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 640px) {
  .hud .quests { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .reveal { opacity: 1; transform: none; }
  .intro__scroll { transform: none; }
  .intro__seal, .intro__title, .intro__load { opacity: 1; }
  .item--legend::before { display: none; }
}
