/* ==========================================
   1. GLOBAL SYSTEM & VARIABLES
   ========================================== */
* { 
  box-sizing: border-box; 
  text-align: center; 
}

:root {
  /* Background and Surfaces */
  --bg: #f3efe7;
  --card: #ffffff;
  --border: #e2e8f0;
  
  /* Text */
  --text: #1f2937;
  --muted: #8297ba;
  
  /* Accent (Muted Sage Green) */
  --accent: #99BAB9;
  --accent-strong: #739382;
  
  /* Shapes & Shadows (Fixed missing shadow tokens) */
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-hover: 0 12px 24px rgba(115, 147, 130, 0.28);
}

html, body { 
  min-height: 100vh; 
}

body { 
  margin: 0; 
  color: var(--text); 
  font-family: Georgia, "Times New Roman", serif; 
  background: linear-gradient(13deg, rgba(255, 248, 238, 0.4), rgba(243, 239, 231, 0.42)), 
              url('/assets/img/wallpaper.png') no-repeat center top / cover fixed;
}

/* Base Elements */
p { line-height: 1.75; color: var(--accent-strong); font-size: 1.5rem; background: rgba(255, 255, 255, 0.635); border-radius: 12px; padding: 12px 16px; }
a { color: inherit; }
h1, h2, h3 { margin-top: 0; text-align: left; }
form { display: grid; gap: 16px; }

/* Combined Structural Layout Widths */
header, footer, main { 
  width: min(1100px, calc(100% - 32px)); 
  margin: 0 auto; 
}


/* ==========================================
   2. REUSABLE CONTAINERS (COMPILED CARDS)
   ========================================== */

#copyRight { line-height: 1.75; color: var(--muted); background: none; padding: 0; font-size: 1em; }

.card-shell, .entry, .modal-content, .authForm, .entry-card, .welcome-card, .add-drama-card { 
  position: relative; 
  border: 1px solid var(--border); 
  border-radius: var(--radius-xl); 
  background: var(--card); 
  box-shadow: var(--shadow); 
}

/* Combined Custom Element Overlays */
.card-shell::before, .entry::before, .modal-content::before, .authForm::before { 
  content: ''; 
  position: absolute; 
  inset: 0; 
  border-radius: inherit; 
  padding: 1px; 
  pointer-events: none; 
}

/* Component Spacing Variations */
.welcome-card {  max-width: 860px; display: grid; padding: clamp(24px, 4vw, 42px); backdrop-filter: blur(12px); margin-top: 5%;  }
.welcome-card h1 { font-size: clamp(30px, 35px, 41px); margin-bottom: 16px; text-align: center; color: var(--muted) }
.welcome-card p { font-size: clamp(18px, 22px, 25px); }
.add-drama-card {text-align: center;display: grid; padding: 22px 24px;
  gap: 14px; 
  width: 100%; 
  max-width: 360px; 
  height: 100%; }
.entry-card { padding: 22px 24px; display: grid; gap: 14px; width: 100%; height: 100%;}
main { padding: 12px 20px 20px; display: grid; gap: 16px; justify-items: stretch; align-content: start; }
.home-page { justify-items: center; }
.home-page .welcome-card { width: min(860px, 100%); margin-inline: auto; }


/* FIX: Forces cards to hug the top tightly and reduces general layout gaps */
.watchlist-page { 
  padding-top: 6px; 
  gap: 8px; 
  align-content: start; 
}

.already-watchlist-page {
  padding-top: 6px;
  gap: 8px;
  align-content: start;
}


/* FIX: Removed 'max-width: 100%' so it relies natively on the base '.add-drama-card' properties */
.already-watchlist-page .add-drama-card {
  margin-top: 0;

}

/* ==========================================
   3. REUSABLE ACTIVE INTERFACES (COMPILED BUTTONS)
   ========================================== */
/* Compiled Base Button Properties */
.card-button, #addDramaBtn, .entryActions button, .modal-actions button, .authForm .g_id_signin div[role='button'], .menu-toggle { 
  display: inline-flex; 
  align-items: center; 
  justify-content: center; 
  min-height: 48px; 
  padding: 0 18px; 
  font: inherit; 
  font-weight: 700; 
  text-decoration: none; 
  cursor: pointer; 
  border-radius: 999px;
  transition: transform 160ms ease, box-shadow 160ms ease, background-color 160ms ease; 
}


/* Compiled Primary Active Actions */
.card-button, #addDramaBtn, .entryActions .edit-btn, .modal-actions #modalSubmit, .modal-actions #editModalSubmit { 
  border: 0;
  background: var(--accent); 
  color: #fff;
  box-shadow: var(--shadow-hover); 
}

/* Compiled Button Hover Interactions */
.card-button:hover, #addDramaBtn:hover, .entryActions .edit-btn:hover, .modal-actions #modalSubmit:hover, .modal-actions #editModalSubmit:hover, 
.card-button:focus-visible, #addDramaBtn:focus-visible, .entryActions .edit-btn:focus-visible, .modal-actions #modalSubmit:focus-visible, .modal-actions #editModalSubmit:focus-visible,
.menu-toggle:hover, .site-menu[open] .menu-toggle, .menu-toggle:focus-visible { 
  transform: translateY(-2px); 
  box-shadow: var(--shadow-hover); 
}

/* Compiled Secondary Neutral Actions */
.entryActions .move-to-viewed-btn, .entryActions .move-to-watchlist-btn, .modal-actions #modalCancel, .modal-actions #editModalCancel, .menu-toggle { 
  color: var(--text); 
  background: rgba(255, 255, 255, 0.92); 
  border: 1px solid var(--border); 
}

/* Unique Button Overrides */
#addDramaBtn { width: 100%; border-radius: var(--radius-lg); padding-block: 18px; font-size: 1.1rem; }
#viewedWatchlistBtn, .move-to-watchlist-btn, .move-to-viewed-btn { margin-left: auto; }

/* ==========================================
   4. NAVIGATION & SITE HEADER
   ========================================== */
header { padding: 24px 0 8px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: relative; }
.site-title { margin: 0; font-size: clamp(2rem, 4vw, 3.2rem); letter-spacing: 0.03em; }
.site-title a { color: var(--text); text-decoration: none; }
.site-menu { position: relative; margin-left: auto; border: 2px solid var(--accent);border-radius: 999px; }
.menu-toggle::-webkit-details-marker { display: none;}

.menu-panel { position: absolute; top: calc(100% + 10px); right: 0; min-width: 220px; display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 20px; background: rgba(255, 255, 255, 0.98); box-shadow: var(--shadow); z-index: 20; }
.menu-panel a { display: block; padding: 12px 14px; border-radius: 14px; text-decoration: none; color: var(--text); font-weight: 700; transition: background-color 160ms ease, transform 160ms ease; }
.menu-panel a:hover, .menu-panel a:focus-visible { background: rgba(153, 186, 185, 0.16); transform: translateX(2px); }

/* ==========================================
   5. COMPONENT DOM VIEWS
   ========================================== */
/* FIX: Changed grid-auto-rows from 1fr to auto to prevent h1 row from expanding */
.indexTopBar { 
  display: grid; 
  gap: 14px; 
 grid-template-columns: repeat(auto-fit, minmax(250px, 320px)); 
  grid-auto-rows: auto; 
  width: 100%; 
  justify-content: start;
}


/* FIX: Erased the margin-bottom entirely to ensure zero heading bleedout down to the grid items */
.indexTopBar > h1 { 
  grid-column: 1 / -1; 
  margin-bottom: 0 !important; 
}

/* Ensure long comment/where text doesn't force uneven heights */
.entryContent, .entryWhere {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-clamp: 4;
  -webkit-line-clamp: 4; /* show up to 4 lines */
  font-size: clamp(0.95rem, 1vw, 1rem);
}
.entryField { display: grid; gap: 6px; min-width: 0; }
.entryLabel { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent-strong); }
.entryWatchlist { font-size: 20px; font-weight: 600; color: var(--muted); }
.entryWatchlist, .entryContent, .entryWhere {
  max-width: 100%;
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}
.entry-card{
  padding: 22px 24px; 
  display: grid; 
  gap: 14px; 
  width: 100%; 
  max-width: 360px; 
  height: 100%;
}
.entryContent, .entryWhere { color: var(--muted); line-height: 1.7; white-space: pre-wrap; }
.entryActions, .card-actions { display: flex; flex-wrap: wrap; gap: 12px; padding-top: 6px; }

/* Form Controls & Inputs */
label { display: grid; gap: 8px; font-weight: 700; color: var(--text); }
input, textarea { width: 100%; border: 1px solid rgba(94, 127, 172, 0.16); border-radius: 16px; padding: 14px 16px; font: inherit; color: var(--text); background: rgba(255, 255, 255, 0.92); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6); }
textarea { min-height: 120px; resize: vertical; }
input:focus, textarea:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(153, 186, 185, 0.22); outline-offset: 2px; }

/* Modals & Authentications */
.modal { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(20, 16, 13, 0.42); backdrop-filter: blur(8px); }
.modal-content { width: min(640px, 100%); padding: clamp(22px, 4vw, 34px); backdrop-filter: blur(12px); }
.modal-content h2 { margin-bottom: 20px; font-size: 1.8rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 12px; justify-content: flex-end; margin-top: 6px; }

.authForm { width: min(560px, 100%); margin: 40px auto 0; padding: clamp(24px, 4vw, 40px); backdrop-filter: blur(12px); }
.authForm img { max-width: 160px; width: 100%; height: auto; display: block; margin: 0 auto 18px; }
.authForm .g_id_signin { display: flex; justify-content: center; }
footer { padding: 8px 0 28px; color: var(--muted); }

/* ==========================================
   6. RESPONSIVE DESIGN (MEDIA QUERIES)
   ========================================== */
@media (max-width: 720px) {
  header, footer, main { width: min(100% - 20px, 1100px); }
  header { align-items: flex-start; }
  .site-title { font-size: clamp(1.8rem, 8vw, 2.5rem); }
  .menu-panel { min-width: 200px; }
  
  .welcome-card, .authForm, .modal-content, .entry-card { border-radius: 22px; }
  .entryActions, .modal-actions, .card-actions { flex-direction: column; }
  .entryActions button, .modal-actions button, .card-button { width: 100%; }
}