/* ============================================================
   Pizza Night G96 — Italian Restaurant Menu Theme
   Mobile-first | Parchment & Candlelight Aesthetic
   ============================================================ */

:root {
  --bg-dark: #1a0f0a;
  --bg-secondary: #2c1810;
  --parchment-light: #fff8e7;
  --parchment-medium: #f5e6cc;
  --parchment-dark: #e8d5b7;
  --accent-red-dark: #8b0000;
  --accent-red-med: #c0392b;
  --accent-red-light: #e74c3c;
  --accent-gold-dark: #b8860b;
  --accent-gold-med: #c5961b;
  --accent-gold-light: #d4a017;
  --accent-green: #2e7d32;
  --text-light: #f5e6cc;
  --text-dark: #2c1810;

  --font-heading: 'Playfair Display', serif;
  --font-body: 'Cormorant Garamond', serif;
  --font-script: 'Great Vibes', cursive;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  background-color: var(--bg-dark);
  color: var(--text-light);
  font-family: var(--font-body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(44, 24, 16, 0.9) 0%, rgba(26, 15, 10, 1) 70%);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

/* Noise texture overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

#app {
  width: 100%;
  max-width: 600px;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding-bottom: 85px;
  display: flex;
  flex-direction: column;
}

/* --- Typography --- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.2;
}

.script-font {
  font-family: var(--font-script);
  font-weight: 400;
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--accent-gold-dark); border-radius: 3px; }

/* --- Form Elements --- */
input[type="text"],
input[type="password"],
textarea {
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--accent-gold-dark);
  color: var(--text-dark);
  font-family: var(--font-body);
  font-size: 1.2rem;
  padding: 10px 4px;
  margin-bottom: 20px;
  outline: none;
  transition: border-color 0.3s ease;
  border-radius: 0;
  -webkit-appearance: none;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
  border-color: var(--accent-red-med);
}

input::placeholder,
textarea::placeholder {
  color: rgba(44, 24, 16, 0.4);
  font-style: italic;
}

.form-label {
  display: block;
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dark);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 4px;
  opacity: 0.7;
}

textarea {
  resize: vertical;
  min-height: 70px;
}

/* --- Buttons --- */
button {
  background: linear-gradient(135deg, var(--accent-red-dark), var(--accent-red-med));
  color: var(--parchment-light);
  border: 1px solid var(--accent-gold-dark);
  padding: 14px 28px;
  font-family: var(--font-heading);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  -webkit-tap-highlight-color: transparent;
}

button:hover {
  background: linear-gradient(135deg, var(--accent-red-med), var(--accent-red-light));
  box-shadow: 0 0 20px rgba(192, 57, 43, 0.4);
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

/* --- View System --- */
.view {
  display: none;
  flex: 1;
  animation: fadeIn 0.4s ease-out;
  width: 100%;
}

.view.active {
  display: flex;
  flex-direction: column;
}

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

/* ============================================================
   PASSWORD GATE
   ============================================================ */
.password-gate {
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 30px 24px;
  min-height: 100vh;
  min-height: 100dvh;
}

.password-gate h1 {
  font-size: clamp(3.5rem, 12vw, 5rem);
  color: var(--accent-gold-light);
  margin-bottom: 4px;
  text-shadow: 0 0 30px rgba(212, 160, 23, 0.25);
  animation: flicker 5s ease-in-out infinite alternate;
}

@keyframes flicker {
  0%, 100% { text-shadow: 0 0 30px rgba(212, 160, 23, 0.25); }
  25% { text-shadow: 0 0 25px rgba(212, 160, 23, 0.35), 0 0 60px rgba(212, 160, 23, 0.1); }
  50% { text-shadow: 0 0 35px rgba(212, 160, 23, 0.4), 0 0 10px rgba(192, 57, 43, 0.2); }
  75% { text-shadow: 0 0 20px rgba(212, 160, 23, 0.3); }
}

.password-gate .subtitle {
  font-family: var(--font-heading);
  font-size: 1rem;
  font-weight: 700;
  color: var(--parchment-dark);
  margin-bottom: 40px;
  letter-spacing: 4px;
  text-transform: uppercase;
}

.password-gate form {
  width: 100%;
  max-width: 300px;
}

.password-gate input {
  color: var(--text-light);
  border-bottom-color: var(--accent-gold-med);
  text-align: center;
  font-size: 1.3rem;
  letter-spacing: 3px;
  margin-bottom: 24px;
}

.password-gate input::placeholder {
  color: rgba(245, 230, 204, 0.35);
  letter-spacing: 1px;
}

.password-gate input:focus {
  border-bottom-color: var(--accent-gold-light);
}

.password-gate button {
  width: 100%;
}

.login-error {
  color: var(--accent-red-light);
  margin-top: 16px;
  font-size: 1.1rem;
  font-style: italic;
  opacity: 0;
  transform: translateY(-5px);
  transition: all 0.3s ease;
}

.login-error.show {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   MENU PAGE — Italian Restaurant Style
   ============================================================ */
.menu-page {
  padding: 16px;
}

.menu-card {
  background: var(--parchment-medium);
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(255, 248, 231, 0.5) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(232, 213, 183, 0.5) 0%, transparent 50%);
  color: var(--text-dark);
  padding: 36px 20px 30px;
  border-radius: 3px;
  box-shadow:
    0 2px 4px rgba(0, 0, 0, 0.2),
    0 8px 24px rgba(0, 0, 0, 0.4),
    inset 0 0 80px rgba(184, 134, 11, 0.06);
  position: relative;
  border: 1px solid var(--accent-gold-dark);
  margin-top: 10px;
}

/* Double border frame */
.menu-card::before {
  content: '';
  position: absolute;
  inset: 6px;
  border: 1px solid var(--accent-gold-med);
  pointer-events: none;
}

.menu-card::after {
  content: '';
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(197, 150, 27, 0.3);
  pointer-events: none;
}

.menu-header {
  text-align: center;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.menu-header h1 {
  font-size: clamp(2rem, 8vw, 2.8rem);
  color: var(--accent-red-dark);
  margin-bottom: 2px;
}

.menu-header .subtitle {
  font-family: var(--font-body);
  font-size: 1rem;
  font-style: italic;
  color: #5a4538;
  letter-spacing: 1px;
}

/* Ornamental divider */
.ornamental-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 16px 0;
  position: relative;
  z-index: 1;
}

.ornamental-divider::before,
.ornamental-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent-gold-med), transparent);
}

.ornamental-divider::before {
  background: linear-gradient(90deg, transparent, var(--accent-gold-med));
}

.ornamental-divider::after {
  background: linear-gradient(90deg, var(--accent-gold-med), transparent);
}

.section-title {
  text-align: center;
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  color: var(--accent-gold-dark);
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}

/* Menu Items */
.menu-item {
  margin-bottom: 22px;
  position: relative;
  z-index: 1;
}

.menu-item-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.menu-item-name {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text-dark);
  background: var(--parchment-medium);
  padding-right: 8px;
  z-index: 2;
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-shrink: 0;
}

.menu-item-rank {
  font-family: var(--font-script);
  color: var(--accent-red-med);
  font-size: 1.6rem;
  min-width: 26px;
}

.menu-item-dots {
  flex: 1;
  border-bottom: 2px dotted var(--accent-gold-med);
  margin: 0 8px;
  position: relative;
  top: -5px;
  opacity: 0.4;
  min-width: 20px;
}

.menu-item-votes {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--accent-red-dark);
  background: var(--parchment-medium);
  padding-left: 8px;
  z-index: 2;
  white-space: nowrap;
  flex-shrink: 0;
}

.menu-item-bottom {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding-left: 32px;
}

.menu-item-ingredients {
  font-style: italic;
  color: #5a4538;
  flex: 1;
  font-size: 1.05rem;
  line-height: 1.4;
}

.menu-item-thumb {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--accent-gold-med);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  flex-shrink: 0;
}

.menu-footer {
  text-align: center;
  font-family: var(--font-script);
  font-size: clamp(2rem, 7vw, 2.8rem);
  color: var(--accent-red-dark);
  margin-top: 24px;
  position: relative;
  z-index: 1;
}

.menu-empty {
  text-align: center;
  padding: 30px 10px;
  font-size: 1.2rem;
  color: #5a4538;
}

.menu-empty-sub {
  font-style: italic;
  font-size: 1rem;
  margin-top: 6px;
  opacity: 0.7;
}

.menu-empty-link {
  display: inline-block;
  margin-top: 16px;
  color: var(--accent-red-dark);
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  text-decoration: none;
  border-bottom: 2px solid var(--accent-gold-med);
  padding-bottom: 2px;
  transition: color 0.3s;
}

.menu-empty-link:hover {
  color: var(--accent-red-med);
}

.menu-empty-note {
  text-align: center;
  padding: 16px 0 8px;
  font-style: italic;
  color: #7a6558;
  font-size: 1rem;
}

/* ============================================================
   ADD PIZZA PAGE
   ============================================================ */
.add-pizza-page {
  padding: 16px;
}

.form-card {
  background: var(--parchment-medium);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(255, 248, 231, 0.4) 0%, transparent 60%);
  color: var(--text-dark);
  padding: 28px 20px;
  border-radius: 6px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  border: 1px solid var(--accent-gold-dark);
}

.form-header {
  text-align: center;
  font-size: clamp(1.8rem, 7vw, 2.4rem);
  color: var(--accent-red-dark);
  margin-bottom: 8px;
}

/* Image Upload */
.image-upload-area {
  border: 2px dashed var(--accent-gold-med);
  border-radius: 8px;
  padding: 24px 12px;
  text-align: center;
  margin-bottom: 20px;
  background: rgba(255, 255, 255, 0.25);
  cursor: pointer;
  transition: all 0.3s ease;
}

.image-upload-area:hover,
.image-upload-area.drag-over {
  background: rgba(255, 255, 255, 0.45);
  border-color: var(--accent-red-med);
}

.upload-icon {
  font-size: 2.8rem;
  margin-bottom: 8px;
}

.upload-text {
  font-size: 1rem;
  color: #7a6558;
  font-style: italic;
  margin-bottom: 4px;
}

.upload-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}

.upload-btn {
  background: var(--bg-secondary);
  color: var(--text-light);
  border: 1px solid var(--accent-gold-dark);
  padding: 10px 16px;
  font-size: 0.9rem;
  letter-spacing: 0.5px;
}

.upload-btn:hover {
  background: var(--bg-dark);
  transform: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* Image Preview */
.image-preview-container {
  display: none;
  margin-bottom: 20px;
}

.image-preview-container.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

.preview-toggles {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}

.preview-toggle {
  background: transparent;
  border: 1px solid var(--accent-gold-dark);
  color: var(--text-dark);
  padding: 6px 16px;
  font-size: 0.9rem;
  border-radius: 20px;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
}

.preview-toggle:hover {
  background: rgba(184, 134, 11, 0.1);
  transform: none;
  box-shadow: none;
}

.preview-toggle.active {
  background: var(--accent-gold-dark);
  color: var(--parchment-light);
}

.preview-image {
  width: 100%;
  max-height: 250px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid var(--accent-gold-dark);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.submit-btn {
  width: 100%;
  margin-top: 8px;
  font-size: 1.1rem;
  padding: 16px;
}

/* ============================================================
   VOTE PAGE
   ============================================================ */
.vote-page {
  padding: 16px;
}

.page-header {
  text-align: center;
  margin-bottom: 8px;
}

.page-header h1 {
  font-size: clamp(2.5rem, 9vw, 3.5rem);
  color: var(--accent-gold-light);
  text-shadow: 0 0 20px rgba(212, 160, 23, 0.2);
}

.page-subtitle {
  color: var(--parchment-dark);
  font-size: 1.1rem;
  font-style: italic;
  margin-top: 2px;
}

/* Sort Controls */
.sort-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 20px;
}

.sort-btn {
  background: transparent;
  border: 1px solid rgba(197, 150, 27, 0.4);
  color: var(--parchment-dark);
  padding: 6px 14px;
  font-size: 0.85rem;
  border-radius: 20px;
  box-shadow: none;
  text-transform: none;
  letter-spacing: 0;
  transition: all 0.25s ease;
}

.sort-btn:hover {
  border-color: var(--accent-gold-med);
  color: var(--accent-gold-light);
  background: rgba(197, 150, 27, 0.08);
  transform: none;
  box-shadow: none;
}

.sort-btn.active {
  background: rgba(197, 150, 27, 0.15);
  border-color: var(--accent-gold-light);
  color: var(--accent-gold-light);
}

/* Vote Cards */
.vote-grid {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.vote-card {
  background: var(--parchment-medium);
  border-radius: 8px;
  overflow: hidden;
  color: var(--text-dark);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--accent-gold-dark);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.vote-card:active {
  transform: scale(0.99);
}

.vote-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  border-bottom: 2px solid var(--accent-gold-med);
  display: block;
}

.vote-card-placeholder {
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: var(--bg-secondary);
}

.vote-card-content {
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.vote-card-info {
  flex: 1;
  min-width: 0;
}

.vote-card-title {
  font-family: var(--font-heading);
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 3px;
  color: var(--accent-red-dark);
}

.vote-card-ingredients {
  font-style: italic;
  font-size: 0.95rem;
  color: #5a4538;
  line-height: 1.3;
}

.vote-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.vote-btn {
  background: transparent !important;
  border: none !important;
  font-size: 2rem;
  cursor: pointer;
  box-shadow: none !important;
  padding: 4px;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  line-height: 1;
}

.vote-btn:hover {
  background: transparent !important;
  box-shadow: none !important;
  transform: scale(1.15);
}

.vote-btn:active {
  transform: scale(0.95);
}

.vote-btn.voted {
  animation: heartBeat 0.5s ease;
}

.vote-count {
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--accent-red-dark);
}

@keyframes heartBeat {
  0% { transform: scale(1); }
  15% { transform: scale(1.35); }
  30% { transform: scale(0.95); }
  45% { transform: scale(1.2); }
  60% { transform: scale(1); }
}

.vote-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--parchment-dark);
  font-size: 1.2rem;
}

/* ============================================================
   BOTTOM NAVIGATION
   ============================================================ */
.nav-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  background: rgba(26, 15, 10, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  justify-content: space-around;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid rgba(197, 150, 27, 0.4);
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: var(--parchment-dark);
  text-decoration: none;
  font-family: var(--font-heading);
  font-size: 0.75rem;
  font-weight: 700;
  gap: 3px;
  transition: all 0.25s ease;
  opacity: 0.55;
  padding: 4px 16px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
  color: var(--accent-gold-light);
  opacity: 1;
}

.nav-icon {
  font-size: 1.4rem;
  line-height: 1;
}

/* ============================================================
   UTILITIES
   ============================================================ */

/* Spinner */
.spinner-container {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 40px;
}

.spinner {
  font-size: 3rem;
  animation: spin 1.5s linear infinite;
  line-height: 1;
}

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

/* Toast Notification */
.toast {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(-120px);
  padding: 12px 24px;
  border-radius: 30px;
  color: white;
  font-family: var(--font-body);
  font-size: 1.1rem;
  font-weight: 600;
  z-index: 10000;
  transition: transform 0.4s cubic-bezier(0.68, -0.3, 0.265, 1.3);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
  max-width: 90vw;
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}

.toast.success {
  background: linear-gradient(135deg, #2e7d32, #388e3c);
}

.toast.error {
  background: linear-gradient(135deg, #c0392b, #e74c3c);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* ============================================================
   RESPONSIVE — Tablet & Desktop
   ============================================================ */
@media (min-width: 480px) {
  .menu-card {
    padding: 44px 32px 36px;
  }

  .form-card {
    padding: 32px 28px;
  }

  .vote-card-img {
    height: 220px;
  }

  .password-gate h1 {
    font-size: 5rem;
  }
}

@media (min-width: 768px) {
  body {
    font-size: 19px;
  }

  .menu-card {
    padding: 50px 40px 40px;
  }

  .menu-item-name {
    font-size: 1.5rem;
  }

  .vote-card-img {
    height: 260px;
  }
}

/* Dark mode media query — already dark by default, but ensure consistency */
@media (prefers-color-scheme: light) {
  /* Keep dark theme regardless of system preference */
  body {
    background-color: var(--bg-dark);
    color: var(--text-light);
  }
}
