/* style.css */

:root {
  /* Oletusfonttikoko tekstikorteille. Tätä muutetaan JavaScriptillä. */
  --card-font-size: 1rem; 
}

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

body {
  /* Tumma, lämmin pohja */
  background: linear-gradient(135deg, #3e1c1d, #1a0a0a);
  color: #fff;
  font-family: "Titillium Web", sans-serif;
  min-height: 100vh;
  padding: 20px;
}

/* --- YLEISET ELEMENTIT --- */

.main-container {
  max-width: 1200px;
  margin: 0 auto;
}

.header {
  text-align: center;
  margin-bottom: 40px;
  padding: 30px 20px;
}

.header h1 {
  font-size: 2.4rem;
  margin-bottom: 8px;
  font-weight: 700;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.date-display {
  font-size: 1.1rem;
  opacity: 0.95;
  font-weight: 400;
  margin-bottom: 20px;
}

/* --- FONTTIKOON SÄÄTIMET --- */
.font-controls {
  display: flex;
  justify-content: center;
  gap: 15px;
  margin-bottom: 10px;
}

.font-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-family: "Titillium Web", sans-serif;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 5px;
}

.font-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
}

.font-btn:active {
  transform: translateY(0);
}

.hero-section {
  text-align: center;
  padding: 20px 0 40px;
}

.hero-text {
  font-size: 1.2rem;
  opacity: 0.9;
  max-width: 600px;
  margin: 0 auto 40px auto;
  line-height: 1.6;
}

.section-title {
  grid-column: 1 / -1;
  font-size: 1.8rem;
  margin: 40px 0 20px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(255,255,255,0.2);
  text-align: center;
  font-weight: 300;
  text-transform: uppercase;
  letter-spacing: 2px;
}

/* --- KORTTIRUUDUKKO --- */


.content-grid {
  display: grid;
  gap: 20px;
  /* MUUTOS: 320px -> 280px. Estää kortin leviämisen näytön yli kapeilla puhelimilla */
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  /* MUUTOS: Varmistaa, että ruudukko keskitetään, jos sarakkeita on vain yksi */
  justify-content: center; 
}

@media (min-width: 1200px) {
  .content-grid {
    grid-template-columns: repeat(3, minmax(320px, 1fr));
  }
}

/* PERUSKORTTI */
.card {
  background: rgba(255, 255, 255, 0.07);
  border-radius: 12px;
  padding: 22px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s ease, box-shadow 0.3s ease, background-color 0.3s ease;
  opacity: 0;
  animation: fadeIn 0.6s ease forwards;
  display: flex;
  flex-direction: column;
}

/* --- TOPOGRAFINEN TAUSTAKUVIO LINKKI-KORTTEIHIN --- */
a.card-link .card {
  position: relative;
  overflow: hidden;
  background-color: #2a1515;
  
  background-image: 
    repeating-radial-gradient(
      circle at 20% 150%, 
      transparent 0, 
      transparent 25px, 
      rgba(255, 255, 255, 0.03) 26px, 
      transparent 27px
    ),
    repeating-radial-gradient(
      circle at 80% -50%, 
      transparent 0, 
      transparent 25px, 
      rgba(255, 255, 255, 0.03) 26px, 
      transparent 27px
    );
  
  box-shadow: inset 0 0 50px rgba(0,0,0,0.6), 0 4px 10px rgba(0, 0, 0, 0.3);
}

a.card-link:hover .card {
  background-color: #381c1c;
  transform: translateY(-4px);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.4), 0 15px 30px rgba(0, 0, 0, 0.4);
}

.card:nth-child(1) { animation-delay: 0.1s; }
.card:nth-child(2) { animation-delay: 0.2s; }
.card:nth-child(3) { animation-delay: 0.3s; }
.card:nth-child(4) { animation-delay: 0.4s; }
.card:nth-child(5) { animation-delay: 0.5s; }
.card:nth-child(6) { animation-delay: 0.6s; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.card-image {
  display: block;
  width: 100%;
  max-width: 260px;
  max-height: 160px;
  margin: 0 auto 12px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  object-fit: cover;
}

.card-header {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid rgba(255, 255, 255, 0.25);
  text-align: center;
}

.card-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: #fff;
}

.card-content {
  color: rgba(255, 255, 255, 0.96);
  flex-grow: 1;
  text-align: center;
}

.card-content pre {
  margin: 0;
  white-space: pre-wrap;
  font-family: inherit;
  /* Dynaaminen fonttikoko muuttujasta */
  font-size: var(--card-font-size);
  line-height: 1.6;
  text-align: left;
  transition: font-size 0.2s ease;
}

.description {
  font-size: 0.9rem;
  opacity: 0.8;
  margin-bottom: 15px;
  min-height: 3rem;
}

.card-action {
  display: inline-block;
  margin-top: 15px;
  padding: 10px 20px;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  text-decoration: none;
  border-radius: 30px;
  font-weight: 600;
  transition: all 0.3s ease;
  z-index: 10;
  position: relative;
}

.card:hover .card-action {
  background: #fff;
  color: #3e1c1d;
  transform: translateY(-2px);
}

/* --- KIRJA-TYYLIT (CSS 3D) --- */

.book-wrapper {
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
  perspective: 1000px;
  padding-top: 20px;
}

.book-3d {
  position: relative;
  width: 140px;
  height: 200px;
  transform-style: preserve-3d;
  transform: rotateY(-25deg);
  transition: transform 0.5s ease;
  box-shadow: 10px 15px 25px rgba(0,0,0,0.5);
}

/* Etukansi */
.book-cover {
  position: absolute;
  top: 0; left: 0; width: 100%; height: 100%;
  border-radius: 2px 6px 6px 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  transform: translateZ(0px);
  backface-visibility: hidden;
  border-left: 4px solid rgba(0,0,0,0.2); /* Sidos */
}

.book-title-text {
  font-size: 1.1rem;
  padding: 10px;
  text-shadow: 1px 1px 2px rgba(0,0,0,0.5);
  border: 1px solid rgba(255,255,255,0.3);
  padding: 15px 5px;
  margin: 0 15px;
  background: rgba(255,255,255,0.1);
}

/* Selkämys */
.book-spine {
  position: absolute;
  top: 0; left: 0;
  height: 100%;
  transform-origin: left;
  transform: rotateY(90deg);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sivut */
.book-pages {
  position: absolute;
  top: 2px; right: 0;
  width: 20px; 
  height: 196px;
  background: linear-gradient(to right, #ccc, #fff 20%, #ddd 40%, #eee 60%, #ccc);
  transform: rotateY(90deg) translateZ(-10px);
  transform-origin: right;
}

/* Hover-efekti kirjalle */
.card:hover .book-3d {
  transform: rotateY(-10deg) rotateX(5deg) scale(1.05);
  box-shadow: 20px 20px 40px rgba(0,0,0,0.6);
}

/* --- LEVY-TYYLIT (CSS Vinyl & Sleeves) --- */

.record-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 25px;
  perspective: 1000px;
  height: 220px; /* Kiinteä korkeus jotta kortit pysyvät linjassa */
  position: relative;
}

/* KOTELO (SLEEVE) YLEINEN */
.record-sleeve {
  position: relative;
  border-radius: 2px;
  box-shadow: 5px 10px 20px rgba(0,0,0,0.4);
  transform-style: preserve-3d;
  transform: rotateY(-15deg) rotateX(5deg);
  transition: transform 0.4s ease, box-shadow 0.4s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
}

/* LEVY (DISC) YLEINEN */
.record-disc {
  border-radius: 50%;
  position: absolute;
  /* Levyn perusmateriaali: Musta vinyyli heijastuksilla */
  background: 
    radial-gradient(circle, #222 25%, transparent 26%), /* Labelin reuna */
    repeating-radial-gradient(
      #111 0, 
      #111 2px, 
      #282828 3px, 
      #111 4px
    );
  box-shadow: 2px 0 10px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: -1; /* Levyn oletusarvo on kotelon sisällä/takana */
  transition: transform 0.6s cubic-bezier(0.2, 0.8, 0.2, 1);
  right: 5px; /* Hieman pilkistää */
}

/* Kiiltoefekti vinyyliin */
.record-disc::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, transparent 40%, rgba(255,255,255,0.1) 50%, transparent 60%);
  pointer-events: none;
}

/* LABEL KESKELLÄ */
.record-label {
  border-radius: 50%;
  position: relative;
  z-index: 2;
  box-shadow: 0 0 5px rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.65rem;
  text-align: center;
  line-height: 1;
  color: #333;
}

/* Labelin reikä */
.record-label::after {
  content: '';
  width: 6px;
  height: 6px;
  background: #000;
  border-radius: 50%;
  position: absolute;
}

/* --- INTERAKTIO (HOVER) --- */

/* Kun kortin päällä on hiiri, levy liukuu ulos ja pyörähtää */
.card:hover .record-sleeve {
  transform: rotateY(0deg) rotateX(0deg) scale(1.02);
  box-shadow: 0 15px 30px rgba(0,0,0,0.5);
  z-index: 10;
}

.card:hover .record-disc {
  /* Liukuu oikealle (ulos kotelosta) ja pyörii hieman */
  transform: translateX(45%) rotate(180deg); 
}

/* --- SOITINSIVUN POIKKEUKSET --- */
/* Soitinsivulla ei ole 'sleeve' elementtiä HTML:ssä, joten varmistetaan että levy näkyy oikein */
.player-container .record-wrapper {
  height: auto;
  perspective: none;
}

.player-container .record-disc {
  position: relative; 
  right: auto;
  width: 260px !important;
  height: 260px !important;
  animation-play-state: paused;
}

/* Palautetaan soittimen levyn animaatio */
.player-container .record-disc.playing {
  animation: spin 3s linear infinite;
}

@keyframes spin {
  100% { transform: rotate(360deg); }
}

/* =========================================
   VÄRITEEMAT & VARIAATIOT (KIRJAT & LEVYT)
   ========================================= */

/* --- 1. NOVELLI / SINGLE ---
   Pääväri: #E97451 (Terracotta) */

/* Kirja: Ohut */
.book-novelli .book-spine {
  width: 15px;
  background: #c0583b; 
}
.book-novelli .book-pages {
  display: none; 
}
.book-novelli::after {
  content: ''; position: absolute; top:0; left:0; width: 100%; height: 100%;
  background: #ddd; transform: translateZ(-15px); border-radius: 2px;
}
.color-novelli {
  background: linear-gradient(135deg, #E97451 0%, #c45d3d 100%);
}

/* Levy: Single (Paperikotelo) */
.sleeve-single {
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, #e8e8e8 30%, #dcdcdc 100%);
  border: 1px solid #ccc;
}
.sleeve-hole {
  position: absolute;
  width: 60px;
  height: 60px;
  background: rgba(0,0,0,0.1);
  border-radius: 50%;
  box-shadow: inset 2px 2px 5px rgba(0,0,0,0.2);
  z-index: 6;
}
.disc-single {
  width: 135px;
  height: 135px;
}
.disc-single .record-label {
  width: 50px; height: 50px;
  background: linear-gradient(135deg, #E97451, #c45d3d);
  color: #fff;
}


/* --- 2. PIENOISROMAANI / EXTENDED ---
   Pääväri: #A0522D (Sienna) */

/* Kirja: Keskikoko */
.book-pienoisromaani .book-spine {
  width: 30px;
  background: #7d3f22; 
}
.book-pienoisromaani::after {
  content: ''; position: absolute; top:0; left:0; width: 100%; height: 100%;
  background: #ddd; transform: translateZ(-30px); border-radius: 2px;
}
.color-pienoisromaani {
  background: linear-gradient(135deg, #A0522D 0%, #7d3f22 100%);
}

/* Levy: EP (Pahvitasku) */
.sleeve-extended {
  width: 170px;
  height: 170px;
  border-left: 2px solid rgba(255,255,255,0.2); 
}
.sleeve-extended.color-pienoisromaani {
  background: linear-gradient(135deg, #A0522D 0%, #7d3f22 100%);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.3), 5px 10px 15px rgba(0,0,0,0.4);
}
.disc-extended {
  width: 165px; 
  height: 165px;
}
.disc-extended .record-label {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, #fff, #e6d0c5);
  color: #7d3f22;
}


/* --- 3. ROMAANI / LONG PLAY ---
   Pääväri: #7C3030 (Dark Red/Brown) */

/* Kirja: Paksu */
.book-romaani .book-spine {
  width: 50px;
  background: #521f1f; 
}
.book-romaani::after {
  content: ''; position: absolute; top:0; left:0; width: 100%; height: 100%;
  background: #ddd; transform: translateZ(-50px); border-radius: 2px;
}
.color-romaani {
  background: linear-gradient(135deg, #7C3030 0%, #521f1f 100%);
  box-shadow: inset 0 0 20px rgba(0,0,0,0.3);
}

/* Levy: LP (Gatefold) */
.sleeve-long {
  width: 200px;
  height: 200px;
}
.sleeve-long.color-romaani {
  background: linear-gradient(135deg, #7C3030 0%, #521f1f 100%);
  background-image: 
    linear-gradient(135deg, #7C3030 0%, #521f1f 100%),
    url("data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHdpZHRoPSc0JyBoZWlnaHQ9JzQnPgo8cmVjdCB3aWR0aD0nNCcgaGVpZ2h0PSc0JyBmaWxsPSIjZmZmIiBmaWxsLW9wYWNpdHk9IjAuMDUiLz4KPC9zdmc+");
}
/* Gatefold selkämys */
.sleeve-long::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 12px;
  background: linear-gradient(90deg, rgba(0,0,0,0.4), rgba(0,0,0,0.1));
  border-right: 1px solid rgba(255,255,255,0.2);
  transform-origin: left;
  transform: rotateY(-90deg);
}
.sleeve-long::after {
  content: '';
  position: absolute;
  top: 1px; bottom: 1px; left: 1px; width: 6px;
  background: rgba(255,255,255,0.15);
}
.disc-long {
  width: 195px;
  height: 195px;
}
.disc-long .record-label {
  width: 70px; height: 70px;
  background: linear-gradient(135deg, #fff, #d9bdbd);
  color: #521f1f;
}

/* --- FLIP-CARD (Adventti yms tekstisivulla) --- */

.flip-card {
  position: relative;
  cursor: pointer;
  perspective: 1000px;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  min-height: 260px;
  transform-style: preserve-3d;
  transition: transform 0.6s ease;
  
  /* MUUTOS: Grid-asettelu varmistaa, että kortti venyy sisällön mukaan */
  display: grid;
  grid-template-areas: "stack";
}

.flip-card-face {
  /* MUUTOS: Molemmat puolet pinotaan samaan grid-soluun */
  grid-area: stack;
  width: 100%;
  backface-visibility: hidden;
  
  /* Poistettu position: absolute, jotta selain laskee korkeuden tekstin perusteella */
  display: flex;
  flex-direction: column;
}

.flip-card-front { 
  transform: rotateY(0deg); 
}

.flip-card-back { 
  transform: rotateY(180deg); 
}

.flip-card.flip-active .flip-card-inner {
  transform: rotateY(180deg);
}

/* Adventti-korttien korostus */
#AdventtiSitatti,
#AdventtiRukous {
  background: #2b4593;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2), 0 0 20px rgba(255, 215, 0, 0.4);
}

/* --- MOBIILIKORJAUKSET --- */
@media (max-width: 480px) {
  body {
    /* Vähennetään reunoja mobiilissa (oli 20px) */
    padding: 10px; 
  }
  
  .header {
    padding: 20px 10px;
  }
  
  /* Jos haluat myös leipätekstin (rukousten) olevan keskitettyä, poista kommentit alta: */
  /* .card-content pre {
    text-align: center; 
  }
  */
}

