@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:
    linear-gradient(rgba(45, 24, 15, 0.28), rgba(45, 24, 15, 0.38)),
    url("../theme/memorial-background.png") center center / cover fixed no-repeat;
  color: var(--ink);
  padding: clamp(14px, 2vw, 28px) clamp(10px, 1.4vw, 16px) clamp(24px, 3vw, 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 50% 20%, rgba(255, 244, 216, 0.18) 0%, transparent 38%),
    linear-gradient(90deg, rgba(38, 15, 8, 0.24), rgba(38, 15, 8, 0.04) 35%, rgba(38, 15, 8, 0.12));
}

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

.memorial-header {
  width: min(1200px, 100%);
  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: clamp(12px, 1.5vw, 16px) clamp(14px, 2vw, 20px);
}

.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: clamp(8px, 1.2vw, 14px);
}

.book-spread {
  position: relative;
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  min-height: clamp(460px, 62svh, 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: clamp(20px, 2.5vw, 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);
}

/* ===== Home Layout ===== */
body.public-page.home-page {
  padding: clamp(14px, 2vw, 28px) clamp(10px, 1.4vw, 16px) clamp(24px, 3vw, 40px);
}

body.public-page.home-page::before {
  display: block;
}

.home-page .memorial-header {
  margin-bottom: clamp(14px, 2vw, 18px);
}

.home-intro {
  width: min(920px, 100%);
  margin: clamp(10px, 1.6vw, 14px) auto 0;
  text-align: center;
  color: #f4e4c7;
  text-shadow: 0 2px 6px rgba(23, 9, 5, 0.45);
}

.home-intro p {
  margin: 0 auto;
  max-width: 780px;
  font-size: clamp(1.06rem, 1.8vw, 1.28rem);
  line-height: 1.38;
}

.home-intro .home-author {
  margin-top: 8px;
  color: #f9ddb4;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: clamp(1.02rem, 1.6vw, 1.18rem);
}

.home-social {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin-top: 10px;
  color: #ffe8bf;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: 1.04rem;
  text-decoration: none;
}

.home-social-icon {
  width: clamp(30px, 3.2vw, 34px);
  height: clamp(30px, 3.2vw, 34px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: #0077ff;
  color: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1;
  box-shadow: 0 7px 16px rgba(0, 40, 100, 0.28);
}

.home-social span:last-child {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.home-social:hover {
  color: #ffffff;
}

.home-cta {
  border: 1px solid #6f1918;
  border-radius: 999px;
  padding: 11px 22px;
  background: linear-gradient(180deg, #a22b28 0%, #7c1b1a 100%);
  color: #f8e5c3;
  font-family: "Philosopher", "Cormorant Garamond", serif;
  font-size: 1.02rem;
  letter-spacing: 0.03em;
  cursor: pointer;
  box-shadow: 0 10px 20px rgba(71, 21, 18, 0.25);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.home-cta:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.home-footer-actions {
  width: min(1200px, 100%);
  margin: clamp(14px, 2vw, 18px) auto 0;
  text-align: center;
}

.home-book .book-spread {
  min-height: clamp(420px, 54svh, 520px);
}

.home-page .alphabet-grid {
  grid-template-columns: 1fr;
  gap: clamp(9px, 1.2vw, 13px);
  max-width: clamp(230px, 28vw, 320px);
  margin: 0 auto;
}

.home-page .alphabet-grid .range {
  min-height: clamp(40px, 5svh, 48px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.2rem, 1.9vw, 1.58rem);
}

.home-page .memorial-page h2,
.home-page .page-caption {
  text-align: center;
}

@media (max-width: 620px) {
  body.public-page.home-page {
    padding: 16px 10px 26px;
  }
}

/* ===== 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), (max-height: 780px) and (min-width: 901px) {
  .book-spread {
    min-height: clamp(420px, 58svh, 560px);
  }

  .memorial-page {
    padding: clamp(18px, 2vw, 22px);
  }

  .home-book .book-spread {
    min-height: clamp(360px, 50svh, 470px);
  }

  .home-page .alphabet-grid .range {
    min-height: 40px;
  }
}

@media (max-width: 980px) {
  body.public-page {
    padding: 18px 10px 24px;
    background:
      linear-gradient(rgba(45, 24, 15, 0.22), rgba(45, 24, 15, 0.34)),
      url("../theme/memorial-background-mobile.png") center top / cover scroll no-repeat;
  }

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

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

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

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

  .home-page .alphabet-grid {
    max-width: min(440px, 100%);
  }

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

@media (max-width: 560px) {
  .alphabet-grid {
    grid-template-columns: 1fr;
  }

  .title-ribbon h1 {
    font-size: 1.28rem;
  }

  .home-social {
    justify-content: center;
    flex-wrap: wrap;
    max-width: 280px;
  }

  .home-cta {
    width: min(100%, 320px);
    padding-right: 14px;
    padding-left: 14px;
  }

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

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

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