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

:root {
  --paper: #efe1c6;
  --paper-deep: #e4d1ad;
  --ink: #3f2a1f;
  --ink-soft: #6b4a35;
  --ribbon: #7b1f1f;
  --ribbon-dark: #571313;
  --gold: #ba8f4e;
  --wood: #5c3527;
  --wood-dark: #3a2118;
  --shadow: rgba(39, 17, 10, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
}

/* ===== Public Pages (Book Style) ===== */
body.public-page {
  font-family: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  background:
    radial-gradient(circle at 10% 20%, rgba(255, 249, 234, 0.72) 0%, transparent 45%),
    radial-gradient(circle at 90% 10%, rgba(197, 142, 80, 0.24) 0%, transparent 35%),
    linear-gradient(140deg, #2f1c15 0%, #5f3a2a 45%, #2a1812 100%);
  color: var(--ink);
  padding: 28px 16px 40px;
  position: relative;
  overflow-x: hidden;
}

body.public-page::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 239, 195, 0.22) 0%, transparent 30%),
    radial-gradient(circle at 80% 25%, rgba(255, 217, 149, 0.16) 0%, transparent 33%),
    repeating-linear-gradient(0deg, rgba(32, 16, 10, 0.08) 0 2px, transparent 2px 6px),
    repeating-linear-gradient(90deg, rgba(25, 11, 6, 0.05) 0 1px, transparent 1px 7px);
}

body.public-page > * {
  position: relative;
  z-index: 1;
}

.memorial-header {
  max-width: 1200px;
  margin: 0 auto 20px;
}

.title-ribbon {
  position: relative;
  margin: 0 auto;
  width: min(100%, 980px);
  background: linear-gradient(180deg, #9f2c2b 0%, var(--ribbon) 48%, var(--ribbon-dark) 100%);
  border: 3px solid #4b1212;
  border-radius: 14px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 215, 170, 0.35);
  text-align: center;
  color: #f8ead0;
  padding: 16px 20px;
}

.title-ribbon::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -7px;
  height: 8px;
  border-radius: 0 0 10px 10px;
  background: linear-gradient(180deg, rgba(46, 12, 13, 0.9), rgba(18, 5, 6, 0.7));
}

.george-mark {
  position: absolute;
  top: 50%;
  width: 88px;
  height: 28px;
  border-radius: 6px;
  transform: translateY(-50%) rotate(-4deg);
  background:
    repeating-linear-gradient(
      -25deg,
      #101010 0 16%,
      #f39a2a 16% 32%
    );
  border: 1px solid rgba(64, 26, 11, 0.85);
  box-shadow: 0 6px 10px rgba(0, 0, 0, 0.25);
}

.george-mark::before {
  content: "";
  position: absolute;
  right: -18px;
  top: 50%;
  width: 20px;
  height: 18px;
  transform: translateY(-50%);
  background:
    repeating-linear-gradient(
      -25deg,
      #101010 0 16%,
      #f39a2a 16% 32%
    );
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  border: 1px solid rgba(64, 26, 11, 0.85);
}

.george-mark.left {
  left: 18px;
}

.george-mark.right {
  right: 18px;
  transform: translateY(-50%) rotate(4deg) scaleX(-1);
}

.title-ribbon::before,
.title-ribbon::after {
  content: "";
  position: absolute;
  top: 50%;
  width: 26px;
  height: 34px;
  background: linear-gradient(180deg, #7a1516, #3b0c0d);
  transform: translateY(-50%);
  box-shadow: inset 0 0 0 2px rgba(255, 213, 165, 0.2);
}

.title-ribbon::before {
  left: -22px;
  clip-path: polygon(100% 0, 0 50%, 100% 100%);
}

.title-ribbon::after {
  right: -22px;
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.title-ribbon h1 {
  margin: 0;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: clamp(1.4rem, 3.2vw, 2.5rem);
  line-height: 1.12;
  letter-spacing: 0.02em;
}

.title-ribbon h1 a {
  color: inherit;
  text-decoration: none;
}

.title-ribbon p {
  margin: 6px 0 0;
  font-size: clamp(1rem, 1.7vw, 1.28rem);
  color: #f5dfbf;
}

.memorial-header.compact .title-ribbon {
  width: min(100%, 720px);
}

.memorial-book {
  position: relative;
  width: min(1200px, 100%);
  margin: 0 auto;
  border-radius: 18px;
  border: 5px solid var(--wood-dark);
  background: linear-gradient(180deg, #6b4030 0%, #4a2a1f 100%);
  box-shadow: 0 18px 36px rgba(0, 0, 0, 0.33);
  padding: 14px;
}

.book-ribbon {
  position: absolute;
  top: -14px;
  width: 150px;
  height: 34px;
  background:
    repeating-linear-gradient(
      -22deg,
      #0f0f0f 0 14%,
      #f09324 14% 28%
    );
  border: 1px solid rgba(58, 29, 18, 0.95);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.28);
  z-index: 4;
}

.book-ribbon.left {
  left: 34px;
  transform: rotate(-10deg);
}

.book-ribbon.right {
  right: 34px;
  transform: rotate(10deg);
}

.book-ribbon::after {
  content: "";
  position: absolute;
  right: -20px;
  top: 50%;
  width: 26px;
  height: 20px;
  transform: translateY(-50%);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
  background:
    repeating-linear-gradient(
      -22deg,
      #0f0f0f 0 14%,
      #f09324 14% 28%
    );
  border: 1px solid rgba(58, 29, 18, 0.95);
}

.book-spread {
  position: relative;
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  min-height: 640px;
  box-shadow: inset 0 0 0 3px rgba(88, 49, 35, 0.4);
}

.book-spread::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 84px;
  background:
    linear-gradient(180deg, rgba(91, 32, 28, 0.35) 0%, rgba(91, 32, 28, 0) 100%);
  pointer-events: none;
  z-index: 3;
}

.book-spread::before {
  content: "";
  position: absolute;
  top: 0;
  left: 50%;
  width: 38px;
  height: 100%;
  transform: translateX(-50%);
  background:
    linear-gradient(90deg, rgba(63, 35, 24, 0.65) 0%, rgba(96, 58, 41, 0.45) 30%, rgba(124, 85, 59, 0.2) 50%, rgba(96, 58, 41, 0.45) 70%, rgba(63, 35, 24, 0.65) 100%);
  pointer-events: none;
  z-index: 1;
}

.memorial-page {
  width: 50%;
  position: relative;
  z-index: 2;
  padding: 28px 34px;
  background:
    radial-gradient(circle at 18% 15%, rgba(255, 247, 225, 0.7), transparent 38%),
    repeating-linear-gradient(180deg, rgba(144, 108, 75, 0.05) 0, rgba(144, 108, 75, 0.05) 2px, transparent 2px, transparent 10px),
    linear-gradient(180deg, var(--paper) 0%, var(--paper-deep) 100%);
}

.memorial-page::after {
  content: "";
  position: absolute;
  inset: 14px;
  border: 1px solid rgba(156, 118, 80, 0.5);
  pointer-events: none;
}

.memorial-page::before {
  content: "";
  position: absolute;
  left: 24px;
  right: 24px;
  top: 24px;
  bottom: 24px;
  background:
    radial-gradient(circle at 0 0, rgba(173, 130, 77, 0.5) 0 2px, transparent 2px),
    radial-gradient(circle at 100% 0, rgba(173, 130, 77, 0.5) 0 2px, transparent 2px),
    radial-gradient(circle at 0 100%, rgba(173, 130, 77, 0.5) 0 2px, transparent 2px),
    radial-gradient(circle at 100% 100%, rgba(173, 130, 77, 0.5) 0 2px, transparent 2px);
  pointer-events: none;
  z-index: 0;
}

.memorial-page > * {
  position: relative;
  z-index: 2;
}

.page-caption {
  margin: 0;
  color: var(--ink-soft);
  text-transform: uppercase;
  font-size: 0.92rem;
  letter-spacing: 0.08em;
}

.memorial-page h2 {
  margin: 8px 0 18px;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  color: #6f221f;
  font-size: clamp(1.4rem, 2vw, 2rem);
  text-shadow: 0 1px 0 rgba(255, 238, 206, 0.7);
}

.alphabet-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.alphabet-grid .range {
  border: 1px solid #a47c4d;
  border-radius: 9px;
  background: linear-gradient(180deg, #f7ecd4 0%, #e5ceaa 100%);
  color: #6d201d;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: clamp(1.1rem, 2.2vw, 1.75rem);
  font-weight: 700;
  text-align: center;
  padding: 13px 10px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.2s ease;
  box-shadow: 0 4px 10px rgba(92, 54, 35, 0.22);
}

.alphabet-grid .range:hover {
  background: linear-gradient(180deg, #fef3dc 0%, #ecd8b8 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(88, 49, 30, 0.3);
}

.search-input {
  width: 100%;
  margin: 4px 0 14px;
  border: 1px solid #ac8556;
  border-radius: 8px;
  background: #fff7e8;
  color: #4f3023;
  padding: 10px 12px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 1.05rem;
}

.hero-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.hero-list li {
  border: 1px solid rgba(145, 106, 70, 0.5);
  border-radius: 8px;
  background: rgba(249, 241, 224, 0.8);
  box-shadow: inset 0 1px 0 rgba(255, 250, 240, 0.7);
}

.hero-list a {
  display: block;
  text-decoration: none;
  color: #5b1d1d;
  font-size: 1.15rem;
  font-weight: 600;
  padding: 12px 14px;
  transition: color 0.15s ease, padding-left 0.15s ease;
}

.hero-list a:hover {
  color: #2f4e2f;
  padding-left: 18px;
}

.empty-note {
  margin: 24px auto 0;
  max-width: 86%;
  border: 1px solid rgba(160, 121, 85, 0.5);
  border-radius: 10px;
  background: rgba(247, 236, 214, 0.82);
  text-align: center;
  padding: 20px 18px;
  box-shadow: 0 6px 16px rgba(88, 50, 34, 0.18);
}

.empty-note h3 {
  margin: 0 0 8px;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  color: #6f211e;
  font-size: 1.5rem;
}

.empty-note p {
  margin: 0;
  color: #5c4433;
  font-size: 1.05rem;
}

.hero-main-photo {
  display: block;
  width: 100%;
  max-height: 440px;
  object-fit: cover;
  border-radius: 10px;
  border: 2px solid rgba(120, 80, 52, 0.55);
  box-shadow: 0 8px 20px rgba(75, 41, 27, 0.28);
  margin-bottom: 14px;
}

.hero-gallery {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.hero-gallery-photo {
  width: 100%;
  height: 120px;
  object-fit: cover;
  border-radius: 7px;
  border: 1px solid rgba(130, 89, 59, 0.5);
}

.hero-name {
  margin: 0;
  color: #6b1e1c;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: clamp(1.6rem, 2.4vw, 2.2rem);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 0 rgba(255, 236, 201, 0.6);
}

.hero-years {
  margin: 8px 0;
  color: #5e412f;
  font-size: 1.2rem;
  font-style: italic;
}

.hero-rank {
  margin: 0 0 14px;
  color: #2f4f30;
  font-size: 1.15rem;
  font-weight: 700;
}

.hero-short,
.hero-full {
  margin: 0 0 12px;
  color: #4c3426;
  font-size: 1.08rem;
  line-height: 1.45;
}

.book-actions {
  text-align: center;
  padding-top: 14px;
}

.public-page .back-btn {
  background: linear-gradient(180deg, #8f2524 0%, #5f1818 100%);
  color: #f8e6c5;
  border: 1px solid #3e0f10;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: 1rem;
  letter-spacing: 0.03em;
  box-shadow: 0 6px 14px rgba(54, 15, 16, 0.25);
}

.public-page .back-btn:hover {
  filter: brightness(1.08);
}

.bg-music-player {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 999;
  width: min(300px, calc(100vw - 24px));
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

/* ===== Admin / Non-public ===== */
body:not(.public-page) {
  padding: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background-color: #f7f3e9;
  color: #333333;
  display: flex;
  flex-direction: column;
}

body:not(.public-page) header {
  text-align: center;
  padding: 20px;
}

body:not(.public-page) h1 {
  margin: 0;
  font-size: 2rem;
  color: #8b0000;
}

body:not(.public-page) h2 {
  margin: 5px 0 0;
  font-size: 1.2rem;
  color: #0b3d0b;
  font-weight: 400;
}

body:not(.public-page) main.book {
  width: 90%;
  max-width: 1000px;
  margin: 20px auto;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  padding: 0;
  overflow: hidden;
}

body:not(.public-page) .book-container {
  display: flex;
  width: 100%;
}

body:not(.public-page) .page {
  width: 50%;
  padding: 20px;
}

body:not(.public-page) .page.left {
  background: linear-gradient(to bottom, #faf4e5, #efe0c7);
  border-right: 1px solid #d9c9a8;
}

body:not(.public-page) .page.right {
  background: linear-gradient(to bottom, #efe0c7, #faf4e5);
  border-left: 1px solid #d9c9a8;
}

body:not(.public-page) .back-btn,
body:not(.public-page) button,
body:not(.public-page) .link-button {
  background: #8b0000;
  color: #ffffff;
  padding: 10px 15px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  margin-top: 15px;
  transition: background 0.2s;
}

body:not(.public-page) .back-btn:hover,
body:not(.public-page) button:hover,
body:not(.public-page) .link-button:hover {
  background: #0b3d0b;
}

body:not(.public-page) .link-button {
  background: none;
  color: #8b0000;
  text-decoration: underline;
  padding: 0;
  margin: 0;
}

body:not(.public-page) form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

body:not(.public-page) label {
  font-weight: 700;
}

body:not(.public-page) input[type="text"],
body:not(.public-page) input[type="number"],
body:not(.public-page) input[type="password"],
body:not(.public-page) textarea {
  padding: 8px;
  font-size: 1rem;
  border: 1px solid #d9c9a8;
  border-radius: 4px;
  width: 100%;
  box-sizing: border-box;
  resize: vertical;
}

body:not(.public-page) textarea {
  min-height: 100px;
}

table.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
}

table.admin-table th,
table.admin-table td {
  border: 1px solid #d9c9a8;
  padding: 8px;
  text-align: left;
}

table.admin-table th {
  background: #8b0000;
  color: #ffffff;
}

.music-settings {
  margin: 15px 0 20px;
  padding: 12px;
  background: #f8f1e1;
  border: 1px solid #d9c9a8;
  border-radius: 6px;
}

.music-settings h3 {
  margin: 0 0 10px;
  color: #8b0000;
}

.music-track-settings {
  border-top: 1px solid #d9c9a8;
  padding-top: 10px;
  margin-top: 10px;
}

.music-track-settings h4 {
  margin: 0 0 8px;
  color: #0b3d0b;
}

.music-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

@media (max-width: 1080px) {
  .book-spread {
    min-height: 560px;
  }

  .memorial-page {
    padding: 22px 22px;
  }
}

@media (max-width: 900px) {
  body.public-page {
    padding: 18px 10px 24px;
  }

  .title-ribbon::before,
  .title-ribbon::after {
    display: none;
  }

  .george-mark {
    width: 58px;
    height: 22px;
  }

  .book-ribbon {
    width: 112px;
    height: 28px;
  }

  .book-spread {
    flex-direction: column;
    min-height: auto;
  }

  .book-spread::before {
    display: none;
  }

  .memorial-page {
    width: 100%;
    min-height: 380px;
  }

  .alphabet-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .hero-main-photo {
    max-height: 380px;
  }
}

@media (max-width: 560px) {
  .george-mark,
  .book-ribbon {
    display: none;
  }

  .alphabet-grid {
    grid-template-columns: 1fr;
  }

  .hero-gallery {
    grid-template-columns: 1fr;
  }

  .memorial-page {
    min-height: 320px;
    padding: 18px 14px;
  }

  .memorial-page::after {
    inset: 9px;
  }
}
