/* Font Faces */
@font-face {
  font-family: "Casablanca";
  src: local("CasablancaAntique"), url("../fonts/CasablancaAntique.ttf") format("truetype");
}

@font-face {
  font-family: "Garamond";
  src: local("Garamond-TrenchCrusade-v2"), url("../fonts/Garamond-TrenchCrusade-v2.otf") format("opentype");
}

/* CSS Variables */
:root {
  font-family: 'Garamond', 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
  --tc-black: #010101;
  --tc-red: #b01f24;
  --tc-white: #fdfdfd;
  --card-radius: 24px;
}

/* Global Styles */
*,
*::before,
*::after {
  box-sizing: border-box;
}

img {
  max-width: 100%;
  display: block;
}

button {
  font-family: inherit;
}

.app {
  min-height: 100vh;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.app__inner {
  max-width: 1100px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 40px 20px 48px;
}

.app--dark {
  background-color: var(--tc-black);
  color: var(--tc-white);
  --card-bg: rgba(255, 255, 255, 0.06);
  --card-border: rgba(255, 255, 255, 0.25);
  --text-muted: rgba(253, 253, 253, 0.8);
  --icon-color: var(--tc-white);
  --secondary-bg: rgba(255, 255, 255, 0.04);
  --input-bg: rgba(255, 255, 255, 0.08);
}

.app--light {
  background-color: var(--tc-white);
  color: var(--tc-black);
  --card-bg: rgba(0, 0, 0, 0.04);
  --card-border: rgba(0, 0, 0, 0.15);
  --text-muted: rgba(1, 1, 1, 0.8);
  --icon-color: var(--tc-black);
  --secondary-bg: rgba(0, 0, 0, 0.03);
  --input-bg: rgba(0, 0, 0, 0.05);
}

.app__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 16px;
}

.app__alert-wrapper {
  width: 100%;
  max-width: 600px;
  margin: 1rem auto 0rem auto;
}

.logo-img {
  height: 96px;
  width: auto;
}

.app__title {
  font-family: 'Casablanca';
  font-size: clamp(2rem, 5vw, 3rem);
  color: var(--tc-red);
  letter-spacing: 0.32em;
  margin: 16px 0 0;
}

#App-buttons {
  margin: 32px auto 40px;
  width: 100%;
  max-width: 720px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 16px;
}

.toolbar__button {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  border: 1px solid var(--tc-red);
  background: transparent;
  color: var(--tc-red);
  font-size: 1rem;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toolbar__button:hover,
.toolbar__button:focus-visible {
  background-color: var(--tc-red);
  color: var(--tc-white);
  outline: none;
}

.mode-toggle {
  display: inline-flex;
  border: 1px solid var(--tc-red);
  border-radius: 12px;
  overflow: hidden;
}

.mode-toggle__button {
  padding: 10px 18px;
  font-size: 0.95rem;
  font-weight: 600;
  background: transparent;
  color: var(--tc-red);
  border: none;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.mode-toggle__button.is-active {
  background-color: var(--tc-red);
  color: var(--tc-white);
}

.mode-toggle__button:not(.is-active):hover,
.mode-toggle__button:not(.is-active):focus-visible {
  background-color: rgba(176, 31, 36, 0.12);
  outline: none;
}

.scenario {
  flex: 1;
}

.scenario__name-card {
  text-align: center;
  padding: 24px 0 12px;
}

.scenario__name {
  font-family: 'Casablanca';
  font-size: clamp(2rem, 4vw, 2.6rem);
  letter-spacing: 0.25em;
  color: var(--tc-red);
  margin: 0;
}

.scenario__grid {
  margin-top: 40px;
  display: grid;
  gap: 32px;
}

@media (min-width: 900px) {
  .scenario__grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.scenario__column {
  display: flex;
  flex-direction: column;
}

.section-card {
  border-radius: var(--card-radius);
  padding: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.section-title {
  font-family: 'Casablanca';
  text-align: center;
  font-size: 2.5rem;
  letter-spacing: 0.2em;
  color: var(--tc-red);
  margin: 0;
}

.section-subtitle {
  font-family: 'Casablanca';
  text-align: center;
  font-size: 1.4rem;
  color: var(--tc-red);
  margin: 8px 0;
}

.selector {
  display: flex;
  justify-content: center;
}

.selector-control {
  width: 100%;
  max-width: 320px;
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  background-color: var(--input-bg);
  color: inherit;
  font-size: 1rem;
}

.selector-control option {
  color: #010101;
}

.app--dark .selector-control {
  color: #fdfdfd;
}

.app--dark .selector-control option {
  color: #010101;
}

.selector-heading {
  font-family: 'Casablanca';
  text-align: center;
  font-size: 1.35rem;
  letter-spacing: 0.15em;
  margin: 0;
}

.description-paragraph {
  margin: 0 0 16px;
  font-size: 1.05rem;
  line-height: 1.6;
  text-indent: 24px;
}

.desc-list {
  font-size: 1.05rem;
  line-height: 1.6;
  font-weight: 600;
  margin: 12px 0;
}

.map-wrapper {
  display: flex;
  justify-content: center;
}

.map-image {
  margin: 24px auto;
  width: 80%;
  max-width: 480px;
  padding: 16px 0;
}

.lock-button {
  margin: 12px auto 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--tc-red);
  background: transparent;
  color: var(--tc-red);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.lock-button:hover,
.lock-button:focus-visible {
  background-color: var(--tc-red);
  color: var(--tc-white);
  outline: none;
}

.important-callout {
  border-radius: 18px;
  border: 1px solid rgba(255, 196, 74, 0.7);
  background-color: rgba(255, 196, 74, 0.2);
  padding: 14px 18px;
  font-size: 1.05rem;
  line-height: 1.6;
  color: #6a3d00;
}

.glorious-deeds {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glorious-deed {
  padding: 12px 0;
}

.glorious-deed h3 {
  font-family: 'Casablanca';
  font-size: 1.75rem;
  margin-bottom: 8px;
}

.glorious-deed p {
  margin: 0;
  font-size: 1.05rem;
  line-height: 1.6;
}

.alert {
  width: 100%;
  border-radius: 18px;
  padding: 14px 20px;
  border: 1px solid transparent;
  position: relative;
}

.alert--success {
  background-color: rgba(56, 142, 60, 0.18);
  border-color: rgba(56, 142, 60, 0.35);
  color: #1b5e20;
}

.alert--danger {
  background-color: rgba(211, 47, 47, 0.18);
  border-color: rgba(211, 47, 47, 0.4);
  color: #880e4f;
}

.alert--warning {
  background-color: rgba(255, 196, 0, 0.2);
  border-color: rgba(255, 196, 0, 0.45);
  color: #5f4200;
}

.alert--info,
.alert--primary {
  background-color: rgba(25, 118, 210, 0.18);
  border-color: rgba(25, 118, 210, 0.4);
  color: #0d47a1;
}

.alert__message {
  margin-right: 36px;
  display: block;
}

.alert__close {
  position: absolute;
  top: 50%;
  right: 12px;
  transform: translateY(-50%);
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 6px;
}

.app__footer {
  text-align: center;
  margin-top: 40px;
  font-size: 0.85rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .app__inner {
    padding: 32px 16px;
  }

  .toolbar__button {
    width: 44px;
    height: 44px;
  }

  .scenario__name {
    letter-spacing: 0.1em;
  }
}

/* Print Styles */
@media print {
  /* Hide theme header and footer (but not plugin header) */
  body > header,
  body > footer,
  footer:not(.app__footer),
  .site-header,
  .site-footer,
  #masthead,
  #colophon,
  nav,
  .navigation,
  .nav-menu,
  .menu,
  .sidebar,
  .widget-area,
  #secondary,
  .top-header {
    display: none !important;
  }

  /* Show plugin header and logo in print */
  .app__header,
  .logo-img {
    display: block !important;
    visibility: visible !important;
  }

  /* Hide ALL buttons and interactive elements */
  .toolbar,
  .toolbar__button,
  .mode-toggle,
  .mode-toggle__button,
  .lock-button,
  .selector,
  .alert,
  .app__alert-wrapper,
  #App-buttons,
  button {
    display: none !important;
  }

  /* Hide specific button SVG icons */
  .toolbar__button svg,
  .mode-toggle__button svg,
  .lock-button svg,
  button svg {
    display: none !important;
  }

  /* Hide specific interactive elements by ID */
  #tc-sg-random,
  #tc-sg-share,
  #tc-sg-print,
  #tc-sg-mode-dark,
  #tc-sg-mode-light,
  #tc-sg-name-lock,
  #tc-sg-objective-lock,
  #tc-sg-deployment-lock,
  #tc-sg-battlefield-lock,
  #tc-sg-deeds-lock,
  #tc-sg-objective-select,
  #tc-sg-deployment-select,
  #tc-sg-battlefield-select {
    display: none !important;
  }

  /* Prevent page breaks inside important sections */
  .section-card {
    page-break-inside: avoid;
    break-inside: avoid;
  }

  /* Prevent breaks inside map wrapper */
  .map-wrapper {
    page-break-inside: avoid;
    break-inside: avoid;
    page-break-before: auto;
    break-before: auto;
    page-break-after: auto;
    break-after: auto;
  }

  /* Optimize map image for print */
  .map-image {
    max-height: 500px;
    width: auto !important;
    max-width: 100%;
    display: block;
    margin: 16px auto;
    object-fit: contain;
  }

  /* Ensure good spacing for print */
  .scenario__grid {
    display: block;
  }

  .scenario__column {
    display: block;
    page-break-inside: avoid;
    break-inside: avoid;
  }

  .section-card {
    margin-bottom: 24px;
  }

  /* Force light mode for print - printers don't handle dark backgrounds well */
  .app,
  .app--dark,
  .app--light {
    background-color: #fdfdfd !important;
    color: #010101 !important;
  }

  /* Use light mode colors for all text elements */
  .section-title,
  .scenario__name,
  .app__title {
    color: #b01f24 !important;
  }

  .description-paragraph,
  .desc-list,
  .glorious-deed p {
    color: #010101 !important;
  }

  .glorious-deed h3 {
    color: #010101 !important;
  }

  .selector-heading {
    color: #010101 !important;
  }

  /* Important callout should maintain its warning colors */
  .important-callout {
    background-color: rgba(255, 196, 74, 0.2) !important;
    border-color: rgba(255, 196, 74, 0.7) !important;
    color: #6a3d00 !important;
  }

  /* Show logo properly in print */
  .logo-img {
    display: block !important;
    visibility: visible !important;
  }

  /* Better text rendering for print */
  body {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }

  /* Align all text to the left for print */
  .section-title,
  .scenario__name,
  .app__title,
  .app__header {
    text-align: left !important;
  }

  .selector-heading {
    text-align: left !important;
  }

  .description-paragraph,
  .desc-list,
  .important-callout {
    text-align: left !important;
  }

  .glorious-deed h3 {
    text-align: left !important;
  }
}
