@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:wght@400;500;600&display=swap');

:root {
  --bg: #141414;
  --bg-2: #141414;
  --ink: #ad8b5c;
  --ink-soft: #ad8b5c;
  --line: rgba(173,139,92,.3);
  --accent: #ad8b5c;
  --border-strong: #000000;
}

:root[data-theme="light"] {
  --bg: #6b1c2d;
  --bg-2: #551122;
  --ink: #ad8b5c;
  --ink-soft: #ad8b5c;
  --line: rgba(173,139,92,.3);
  --accent: #ad8b5c;
  --border-strong: #3a0c18;
}

* { box-sizing: border-box; }

html, body {
  min-height: 100dvh;
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: 'EB Garamond', Georgia, serif;
  letter-spacing: 0.025em;
  overflow-x: hidden;
  transition: background .25s ease, color .25s ease;
}

a { color: inherit; text-decoration: none; }

/* Fixed corner icon buttons */
.icon-btn {
  position: fixed;
  top: max(10px, calc(env(safe-area-inset-top) + 4px));
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 60;
  transition: transform .2s, opacity .2s;
}
.icon-btn:hover { transform: translateY(-1px); opacity: .75; }
.icon-btn svg { width: 17px; height: 17px; display: block; }
.icon-btn.spin { animation: spin-once .45s ease; }
@keyframes spin-once {
  from { transform: rotate(0deg); }
  50% { transform: rotate(160deg); }
  to { transform: rotate(360deg); }
}
.icon-btn--back { left: max(20px, calc(env(safe-area-inset-left) + 14px)); }
.icon-btn--theme {
  right: max(20px, calc(env(safe-area-inset-right) + 14px));
  color: var(--border-strong);
}

/* Index grid — carrossel horizontal, uma carta de cada vez */
.grid {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 28px;
  padding: max(3px, calc(env(safe-area-inset-top) + 3px)) 0 3px;
  height: 100dvh;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  touch-action: pan-x;
}

.grid .spacer {
  flex: 0 0 calc(50vw - 18px);
  scroll-snap-align: none;
}

.card {
  display: block;
  flex: 0 0 auto;
  scroll-snap-align: center;
  scroll-snap-stop: always;
  width: min(calc(100vw - 30px), calc((100dvh - 30px) * 420 / 770));
  cursor: pointer;
}

.card .card-anim {
  aspect-ratio: 420 / 770;
  opacity: 0;
  transform: translateX(56px);
  transition: opacity .6s cubic-bezier(.22,.7,.32,1), transform .6s cubic-bezier(.22,.7,.32,1);
}
.card.in-view .card-anim {
  opacity: 1;
  transform: translateX(0);
}

.card .flip {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: perspective(1200px) rotateY(0deg);
  transition: transform .7s cubic-bezier(.2,.8,.2,1);
}
.card.is-flipped .flip {
  transform: perspective(1200px) rotateY(180deg);
}

.card .face {
  position: absolute;
  inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  border-radius: 50px;
  overflow: hidden;
  background: var(--bg-2);
  border: 6px solid var(--border-strong);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 60px -28px rgba(0,0,0,.22);
}
.card .face--front {
  z-index: 2;
  -webkit-transform: rotateY(0deg);
  transform: rotateY(0deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.card .face--front .title {
  font-size: 30px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.58em;
  text-shadow: 0 4px 14px rgba(0,0,0,.85), 0 2px 4px rgba(0,0,0,.9);
  order: 1;
}
.card .face--front .label {
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-top: 48px;
  padding: 0 16%;
  text-shadow: 0 3px 10px rgba(0,0,0,.8);
  order: 2;
}
.card .face--back {
  -webkit-transform: rotateY(180deg);
  transform: rotateY(180deg);
  z-index: 1;
}
.card .face--back img {
  width: 100%; height: 100%; object-fit: contain; display: block;
}

#coverScreen {
  position: fixed;
  inset: 0;
  z-index: 100;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(3px, calc(env(safe-area-inset-top) + 3px)) 0 3px;
  background: #141414;
  transition: opacity .5s ease, transform .5s ease;
}
#coverScreen.opening {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}
#coverScreen .cover-face {
  width: min(calc(100vw - 30px), calc((100dvh - 30px) * 420 / 770));
  aspect-ratio: 420 / 770;
  border-radius: 50px;
  border: 6px solid #000000;
  background: #141414;
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 60px -28px rgba(0,0,0,.22);
  display: flex;
  align-items: center;
  justify-content: center;
}
#coverScreen .cover-word {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}
#coverScreen .cover-word img {
  width: 36%;
  display: block;
  margin: 0 auto;
  transform: translateY(-24px);
  filter: drop-shadow(0 16px 28px rgba(0,0,0,.85));
}
.cover-card .cover-word small {
  display: block;
  font-size: 13px;
  letter-spacing: 0.3em;
  margin-top: 16px;
}

.credit {
  text-align: center;
  padding: 20px 6vw 60px;
  font-size: 15px;
  color: var(--ink-soft);
}

.reveal {
  opacity: 0;
  transform: translateY(32px);
  transition: opacity .7s ease, transform .7s ease;
}
.reveal.reveal-in {
  opacity: 1;
  transform: translateY(0);
}

/* Detail page — a página inteira é a própria carta expandida */
.page-card {
  margin: max(48px, calc(env(safe-area-inset-top) + 42px)) 12px 12px;
  min-height: calc(100dvh - max(60px, calc(env(safe-area-inset-top) + 54px)));
  border-radius: 50px;
  border: 6px solid var(--border-strong);
  background: var(--bg-2);
  box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 24px 60px -28px rgba(0,0,0,.22);
  overflow: hidden;
}

.hero {
  padding: calc(env(safe-area-inset-top, 0px) + 68px) 6vw 40px;
  text-align: center;
}
.hero .specimen {
  display: inline-block;
  max-width: 100%;
  font-size: clamp(52px, 9.5vw, 148px);
  line-height: 0.95;
  word-break: break-word;
  white-space: nowrap;
  text-shadow: 0 6px 20px rgba(0,0,0,.8);
  opacity: 0;
  transition: opacity .35s ease;
}
.hero .tagline {
  margin-top: 46px;
  padding: 0 12%;
  font-size: 22px;
  color: var(--ink-soft);
}

.info {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  justify-content: center;
  gap: 24px;
  padding: 32px 6vw;
  text-align: center;
}
.info .label {
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin-bottom: 6px;
}
.info .value { font-size: 19px; letter-spacing: 0.05em; }

.desc {
  padding: 32px 6vw 48px;
  max-width: 760px;
  margin: 0 auto;
  font-size: 20px;
  line-height: 1.5;
  letter-spacing: 0.015em;
  text-align: justify;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  padding: 40px 6vw 90px;
}
.gallery a {
  display: block;
  border-radius: 32px;
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: 0 10px 24px -14px rgba(0,0,0,.6);
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.gallery img {
  width: 100%; display: block;
  transition: transform .4s ease;
}
.gallery a:hover img { transform: scale(1.03); }

@media (max-width: 640px) {
  .top { padding: 84px 5vw 20px; }
  .hero { padding: calc(env(safe-area-inset-top, 0px) + 40px) 6vw 32px; }
  .gallery { grid-template-columns: 1fr; }
}
