@import url(https://fonts.googleapis.com/css?family=Lato:300italic,400,600);

/* ----- Reset ve temel ayarlar ----- */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body { 
  height: 100%; 
  margin: 0; 
  padding: 0;
  overflow: hidden;
  touch-action: manipulation;
}

body {
  background: linear-gradient(135deg, #000000ec 0%, #1a1a1a 100%);
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: stretch;
  justify-items: center;
  font-family: 'Lato', sans-serif;
  position: fixed;
  width: 100vw;
  height: 100vh;
  top: 0;
  left: 0;
}

/* ----- Pasta + mum sahnesi ----- */
.stage {
  grid-row: 1;
  position: relative;
  width: min(85vw, 520px);
  height: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1;
  padding-bottom: clamp(10px, 5vh, 30px);
}

/* SVG responsive optimizasyon */
#cake {
  display: block;
  width: 100%;
  height: auto;
  max-width: 520px;
  max-height: 70vh;
}

/* ----- Mum gövdesi ----- */
.cake {
  background: linear-gradient(180deg, #ffffff 0%, #f8f8f8 100%);
  border-radius: 10px 10px 8px 8px;
  position: absolute;
  left: 50%;
  bottom: 0;
  width: clamp(10px, 2.5vw, 14px);
  height: clamp(50px, 12vw, 68px);
  transform: translate(-50%, 0);
  opacity: 0;
  backface-visibility: hidden;
  z-index: 2;
  animation: candleDrop 600ms 6s ease-out forwards;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.cake:after, .cake:before {
  background: linear-gradient(90deg, rgba(255, 0, 0, 0.5) 0%, rgba(255, 50, 50, 0.3) 100%);
  content: "";
  position: absolute;
  width: 100%;
  height: 2px;
  border-radius: 1px;
}
.cake:after { top: 30%; left: 0; }
.cake:before { top: 55%; left: 0; }

/* Mum pozisyonları - responsive */
.cake.c1 { left: calc(50% - clamp(20px, 5vw, 35px)); }
.cake.c2 { left: 50%; }
.cake.c3 { left: calc(50% + clamp(20px, 5vw, 35px)); }

@keyframes candleDrop {
  0% { 
    transform: translate(-50%, -120px); 
    opacity: 0; 
    filter: blur(2px);
  }
  80% {
    transform: translate(-50%, 5px);
    opacity: 1;
    filter: blur(0px);
  }
  100% { 
    transform: translate(-50%, 0); 
    opacity: 1; 
    filter: blur(0px);
  }
}

/* ----- Alevler ----- */
.fuego {
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  position: absolute;
  top: -18px;
  left: 50%;
  margin-left: -3px;
  width: 6px;
  height: clamp(14px, 3.5vw, 20px);
  z-index: 3;
  opacity: 0;
  will-change: transform, opacity;
}

.fuego:nth-child(1) { animation: fuego 2.2s 6.5s infinite ease-in-out; }
.fuego:nth-child(2) { animation: fuego 1.8s 6.5s infinite ease-in-out; }
.fuego:nth-child(3) { animation: fuego 1.4s 6.5s infinite ease-in-out; }
.fuego:nth-child(4) { animation: fuego 1s 6.5s infinite ease-in-out; }
.fuego:nth-child(5) { animation: fuego 0.8s 6.5s infinite ease-in-out; }

@keyframes fuego {
  0%, 100% {
    background: radial-gradient(ellipse at center, rgba(254, 248, 97, 0.9) 0%, rgba(255, 150, 0, 0.7) 40%, rgba(255, 50, 0, 0.3) 100%);
    box-shadow: 0 0 20px 5px rgba(248, 233, 209, 0.4);
    transform: translateY(0) scale(1) rotate(-2deg);
    opacity: 1;
  }
  25% {
    transform: translateY(-8px) scale(1.1) rotate(1deg);
    opacity: 0.9;
  }
  50% {
    background: radial-gradient(ellipse at center, rgba(255, 100, 0, 0.8) 0%, rgba(255, 50, 0, 0.5) 60%, transparent 100%);
    box-shadow: 0 0 30px 8px rgba(248, 233, 209, 0.3);
    transform: translateY(-15px) scale(0.8) rotate(-1deg);
    opacity: 0.8;
  }
  75% {
    transform: translateY(-5px) scale(1.05) rotate(2deg);
    opacity: 0.95;
  }
}

/* Söndürülünce alevler */
.fuego.off, .stage.blown .fuego { 
  animation: flameOut 400ms ease-out forwards !important; 
}

@keyframes flameOut {
  0% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(0); }
}

/* ----- Metin bölümü ----- */
.text {
  grid-row: 2;
  width: 100%;
  min-height: clamp(60px, 10vh, 100px);
  color: #c4a484;
  font-weight: 400;
  font-style: italic;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  padding: 10px 20px;
  background: rgba(0, 0, 0, 0.1);
  backdrop-filter: blur(5px);
}

.text h1 { 
  font-size: clamp(18px, 4vw, 26px); 
  margin: 0; 
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  font-weight: 600;
}

.name { 
  font-size: clamp(16px, 3.5vw, 22px); 
  font-weight: 700; 
  margin: 0; 
  color: #d4b494;
}

/* ----- Kutlama canvas ----- */
#celebrateCanvas {
  position: fixed; 
  inset: 0;
  width: 100vw; 
  height: 100vh;
  display: none; 
  z-index: 9999; 
  pointer-events: none;
}
#celebrateCanvas.is-on { display: block; }
#celebrateCanvas.dimmed {
  opacity:.25; 
  filter: blur(1px) brightness(.6); 
  transition: opacity .25s ease, filter .25s ease;
}

/* ----- Uyarı mesajları ----- */
.warning-message {
  position: fixed !important;
  bottom: clamp(20px, 5vh, 40px) !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  background: linear-gradient(135deg, #ffcc00 0%, #ffa500 100%) !important;
  color: #000 !important;
  padding: clamp(10px, 3vw, 18px) clamp(15px, 4vw, 30px) !important;
  border-radius: 12px !important;
  z-index: 10000 !important;
  font-size: clamp(14px, 3.5vw, 18px) !important;
  font-weight: 600 !important;
  text-align: center !important;
  max-width: 90vw !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4) !important;
  animation: warningPulse 2s infinite ease-in-out !important;
  backdrop-filter: blur(10px) !important;
}

@keyframes warningPulse {
  0%, 100% { transform: translateX(-50%) scale(1); opacity: 1; }
  50% { transform: translateX(-50%) scale(1.02); opacity: 0.9; }
}

/* ----- Mobil cihazlar için optimizasyonlar ----- */
@media (max-width: 480px) {
  .stage { width: 90vw; padding-bottom: 15px; }
  .cake { width: 12px; height: 55px; }
  .fuego { width: 5px; height: 16px; top: -16px; margin-left: -2.5px; }
  .text { min-height: 80px; padding: 8px 15px; }
  .cake.c1 { left: calc(50% - 25px); }
  .cake.c3 { left: calc(50% + 25px); }
}

/* ----- Küçük telefonlar (iPhone SE vb.) ----- */
@media (max-width: 375px) {
  .stage { width: 95vw; padding-bottom: 10px; }
  .cake { width: 10px; height: 50px; }
  .fuego { width: 4px; height: 14px; top: -14px; margin-left: -2px; }
  .cake.c1 { left: calc(50% - 20px); }
  .cake.c3 { left: calc(50% + 20px); }
}

/* ----- Tablet boyutları ----- */
@media (min-width: 768px) and (max-width: 1024px) {
  .stage { width: 70vw; max-width: 600px; }
  .cake { width: 14px; height: 70px; }
  .fuego { width: 7px; height: 22px; top: -20px; margin-left: -3.5px; }
  .cake.c1 { left: calc(50% - 40px); }
  .cake.c3 { left: calc(50% + 40px); }
}

/* ----- Büyük ekranlar ----- */
@media (min-width: 1025px) {
  .stage { width: 60vw; max-width: 520px; }
  .cake { width: 14px; height: 68px; }
  .fuego { width: 7px; height: 20px; top: -18px; margin-left: -3.5px; }
  .cake.c1 { left: calc(50% - 35px); }
  .cake.c3 { left: calc(50% + 35px); }
}

/* ----- Yatay mod optimizasyonları ----- */
@media (orientation: landscape) and (max-height: 500px) {
  .stage { padding-bottom: 5px; }
  #cake { max-height: 60vh; }
  .text { min-height: 60px; padding: 5px 15px; }
  .cake { height: clamp(40px, 8vw, 55px); }
  .fuego { height: clamp(12px, 3vw, 16px); top: clamp(-14px, -3vw, -16px); }
}

/* ----- Performance optimizasyonları ----- */
.cake, .fuego {
  will-change: transform, opacity;
  transform-style: preserve-3d;
}

/* Animasyonları durdur eğer kullanıcı hareket azaltma tercih ediyorsa */
@media (prefers-reduced-motion: reduce) {
  .cake { animation-duration: 0.3s !important; }
  .fuego { animation-duration: 1s !important; }
  .warning-message { animation: none !important; }
}

/* ----- iOS Safari için özel düzeltmeler ----- */
@supports (-webkit-appearance: none) {
  body { -webkit-overflow-scrolling: touch; }
  .stage { -webkit-transform: translateZ(0); transform: translateZ(0); }
}

/* === TOAST === */
/* SCRIM: tüm ekranı kaplasın; sadece görünürken tıklanabilir */
#toastScrim {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  opacity: 0;
  pointer-events: none;
  z-index: 10000;
  transition: opacity .2s ease;
}
#toastScrim.show {
  opacity: 1;
  pointer-events: auto;
}

/* TOAST: scrim'in ÜSTÜNDE */
#toast.toast {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  max-width: 640px;
  margin: 0 auto;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: auto;
  z-index: 10001;
  transition: transform .2s ease, opacity .2s ease;
  background: #fff;
  color: #111;
  border: 1px solid rgba(0,0,0,.08);
  border-radius: 14px;
  padding: 16px 44px 14px 16px;
  box-shadow: 0 20px 45px rgba(0,0,0,.35);
}
#toast.show { opacity: 1; transform: translateY(0); }

/* Karanlık tema */
@media (prefers-color-scheme: dark){
  #toast.toast{
    background: rgba(28,28,32,.96);
    color: #fff;
    border-color: rgba(255,255,255,.08);
  }
}

.toast p{ margin: 0 0 10px; line-height: 1.35; font-weight: 700; font-size: 1.05em; }

.actions{ display:flex; gap:10px; align-items:center; }
.btn{
  border: none; border-radius: 10px; padding: 12px 16px;
  background: #6a5acd; color:#fff; font-weight: 800; cursor: pointer;
}
.btn:disabled{ opacity:.6; cursor:not-allowed; }
.ghost{ background: transparent; color:#444; border:1px solid rgba(0,0,0,.12); }
@media (prefers-color-scheme: dark){ .ghost{ color:#c9c9c9; border-color:rgba(255,255,255,.14); } }

.close{
  position:absolute; right:8px; top:6px; width:32px; height:32px;
  border-radius:8px; border:none; background:transparent; color:#888;
  font-size:22px; line-height:1; cursor:pointer;
}
.close:focus{ outline:2px solid rgba(0,0,0,.2); outline-offset:2px; }

.digits{
  font-variant-numeric: tabular-nums;
  font-size: 3rem; font-weight: 800; letter-spacing: .03em;
  text-align: center; margin: 6px 0 8px;
}
.final{ text-align:center; font-weight:700; }
.hint{ font-size:12px; color:#777; margin-top:6px; text-align:center; }
@media (prefers-color-scheme: dark){ .hint{ color:#bbb; } }

#toast button,
#toast [role="button"] {
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ========================================================= */
/* =================== EKLEMELER (YENİ) ==================== */
/* ========================================================= */

/* Üst bar (hamburger) + Drawer */
.appbar{
  position: fixed; top:0; left:0; right:0; height:52px;
  display:flex; align-items:center; gap:10px; padding:0 12px;
  z-index: 10002;
  
  color:#fff; border-bottom:1px solid rgba(255,255,255,.06);
}
.hamburger{ width:40px; height:40px; font-size:22px; border:0; background:transparent; color:#fff; cursor:pointer; }
.appbar-title{ font-weight:800; letter-spacing:.3px; }

.drawer{
  position:fixed; top:0; left:0; bottom:0; width:260px;
  background:#1c1c22; transform:translateX(-100%); transition:transform .25s ease;
  z-index:10003; box-shadow: 0 20px 50px rgba(0,0,0,.45); padding-top:60px; color:#fff;
}
.drawer.show{ transform:translateX(0); }
.drawer-scrim{
  position:fixed; inset:0; background:rgba(0,0,0,.45);
  opacity:0; pointer-events:none; transition:opacity .2s ease; z-index:10002;
}
.drawer-scrim.show{ opacity:1; pointer-events:auto; }
.drawer-nav{ display:flex; flex-direction:column; gap:2px; padding:12px; }
.drawer-link{ color:#fff; text-decoration:none; padding:12px 10px; border-radius:10px; }
.drawer-link:hover{ background:rgba(255,255,255,.06); }

/* Fotoğraflar açıkken tüm arka planı KİLİTLE */
html.photos-open, body.photos-open { overflow: hidden !important; }

/* Fotoğraflar SAYFASI (tam ekran, siyah, en üst) */
#page-photos{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483000 !important;  /* toast/drawer/canvas üstü */
  background: #000 !important;
  pointer-events: auto !important;
  padding: 56px 14px 16px !important;
  overflow: auto !important;
}

/* Foto sayfası topbar */
#page-photos .photos-topbar{
  position: sticky; top: -8px; z-index: 1;
  display:flex; align-items:center; gap:8px;
  padding: 8px 0 12px; background:#000;
}
.photos-close{
  width:40px; height:40px; border:0; border-radius:10px;
  background: rgba(255,255,255,.12); color:#fff; font-size:22px; cursor:pointer;
}
.photos-title{ color:#fff; font-weight:800; font-size:18px; letter-spacing:.3px; }

/* Foto grid */
.photos-wrap{ max-width:1100px; margin:0 auto; }
.photo-grid{
  display:grid; gap:8px;
  grid-template-columns: repeat(auto-fill, minmax(140px,1fr));
}
.photo-grid .cell{ position:relative; padding-top:100%; overflow:hidden; border-radius:12px; background:#222; cursor:pointer; }
.photo-grid img{ position:absolute; inset:0; width:100%; height:100%; object-fit:cover; display:block; }

/* Lightbox (tam ekran, siyah) */
.lightbox{
  position: fixed; inset: 0; background:#000;
  display:none; align-items:center; justify-content:center;
  z-index: 2147483600; /* #page-photos üstü */
}
.lightbox.show{ display:flex; }
.lightbox img{ max-width:92vw; max-height:90vh; border-radius:10px; box-shadow:0 20px 60px rgba(0,0,0,.7); }
.lb-close, .lb-prev, .lb-next{
  position:absolute; width:48px; height:48px; border-radius:10px; border:0; background:rgba(255,255,255,.12);
  color:#fff; font-size:28px; cursor:pointer;
}
.lb-close{ top:16px; right:16px; }
.lb-prev { left:16px; top:50%; transform:translateY(-50%); }
.lb-next { right:16px; top:50%; transform:translateY(-50%); }
.lb-counter{ position:absolute; bottom:16px; left:50%; transform:translateX(-50%); color:#fff; font-weight:700; background:rgba(0,0,0,.35); padding:6px 10px; border-radius:8px; }

@media (max-width:480px){
  .lb-prev, .lb-next{ top:50%; transform:translateY(-50%); }
}
.appbar{ z-index: 2147484000 !important; }
#page-photos{
  z-index: 2147483600 !important;
  background: #000 !important;
  padding: calc(16px + env(safe-area-inset-top)) 14px 16px !important;
  touch-action: pan-y !important;
}
#page-photos .photos-topbar{
  position: sticky; top: 0; background:#000; z-index: 5;
}

.lightbox{ z-index: 2147484000 !important; }

/* === ÜST KATMAN SIRASI (Z-INDEX) & DAVRANIŞ === */

/* Drawer en üstte, Appbar onun altında KALSIN ama Scrim'in ÜSTÜNDE olsun */
.drawer{ z-index: 2147483855 !important; }
.appbar{ z-index: 2147483850 !important; }
.drawer-scrim{ z-index: 2147483840 !important; } 


/* Foto sayfası: TAM ekran ama appbar ALTINDA kalsın */
#page-photos{
  position: fixed !important;
  inset: 0 !important;
  z-index: 2147483600 !important;     /* appbar/drawer'dan düşük */
  background: #000 !important;
  pointer-events: auto !important;
  /* appbar yüksekliği (~52px) + nefes payı + iOS güvenli alan */
  padding: calc(52px + 12px + env(safe-area-inset-top)) 14px 16px !important;
  overflow: auto !important;
  touch-action: pan-y !important;     /* dikey kaydır, yatay jestleri lightbox kullanır */
}

/* Foto sayfası üst barı (içteki) */
#page-photos .photos-topbar{
  position: sticky; top: 0; z-index: 5; background:#000;
}

/* Lightbox en üstte kalsın (gerekirse appbar'ın da üstü) */
.lightbox{
  z-index: 2147483900 !important;
}

/* Fotoğraflar açıkken sayfa kaymasını kitle (arka plan) */
html.photos-open, body.photos-open { overflow: hidden !important; }

/* Fotoğraflar açıkken APPBAR görünür ve tıklanır kalsın */
html.photos-open .appbar{
  display: flex !important;
  pointer-events: auto !important;
}
