/* ==========================================================================
   PROROČIŠTE — Dürer Aesthetic
   Inspired by Albrecht Dürer's Northern Renaissance engravings (c. 1500)
   Palette: parchment, sepia, lampblack
   Typography: Cinzel (engraved Roman capitals) + EB Garamond (humanist serif)
   ========================================================================== */

/* --- Fonts --- */
@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;500;600;700&family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400;1,500&display=swap');

/* --- Custom Properties --- */
:root {
  --parchment:    #f0e8d8;
  --parchment-dk: #e0d5c0;
  --ink:          #1a1410;
  --sepia:        #5c4a3a;
  --sepia-light:  #8a7560;
  --sepia-faint:  #c4b49a;
  --gold-dim:     #9e8a6a;
  --bone:         #faf5ec;

  --ff-gothic:    'Cinzel', 'Georgia', serif;
  --ff-body:      'EB Garamond', 'Georgia', serif;

  --border-thin:  1px solid var(--ink);
  --border-thick: 2px solid var(--ink);
  --border-ornate: 3px double var(--ink);
}

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

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--ff-body);
  color: var(--ink);
  background: var(--parchment);
  line-height: 1.65;
  min-height: 100vh;

  /* Subtle parchment texture via noise gradient */
  background-image:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(26, 20, 16, 0.008) 2px,
      rgba(26, 20, 16, 0.008) 4px
    ),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 2px,
      rgba(26, 20, 16, 0.006) 2px,
      rgba(26, 20, 16, 0.006) 4px
    );
}

/* --- Page Frame — the broadsheet border --- */
.page-frame {
  max-width: 820px;
  margin: 2rem auto;
  padding: 2.5rem;
  position: relative;
  background: var(--bone);

  /* Triple border — outer thick, gap, inner thin */
  border: 3px solid var(--ink);
  outline: 1px solid var(--ink);
  outline-offset: 6px;
  box-shadow:
    0 0 0 8px var(--parchment),
    0 0 0 9px var(--ink),
    0 8px 32px rgba(26, 20, 16, 0.15);
}

/* Corner ornaments */
.page-frame::before,
.page-frame::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid var(--ink);
}

.page-frame::before {
  top: 10px;
  left: 10px;
  border-right: none;
  border-bottom: none;
}

.page-frame::after {
  bottom: 10px;
  right: 10px;
  border-left: none;
  border-top: none;
}

/* --- Typography --- */
h1, h2, h3 {
  font-family: var(--ff-gothic);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--ink);
}

h1 {
  font-size: 2.4rem;
  text-align: center;
  margin-bottom: 0.2rem;
  line-height: 1.1;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h2 {
  font-size: 1.6rem;
  text-align: center;
  margin-bottom: 1rem;
}

h3 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 0.95rem;
  text-align: center;
  color: var(--sepia);
  margin-bottom: 2rem;
  letter-spacing: 0.04em;
}

/* --- Ornamental Dividers --- */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.8rem 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 0;
  border-top: 1px solid var(--sepia-faint);
}

.divider-symbol {
  font-family: var(--ff-gothic);
  font-size: 1.2rem;
  color: var(--sepia);
  line-height: 1;
}

/* Simple line divider */
.rule {
  border: none;
  border-top: 1px solid var(--sepia-faint);
  margin: 1.5rem 0;
}

/* Thick double rule */
.rule-double {
  border: none;
  border-top: 3px double var(--sepia);
  margin: 2rem 0;
}

/* --- Gothic Buttons --- */
.btn-gothic {
  display: inline-block;
  font-family: var(--ff-gothic);
  font-size: 1.1rem;
  color: var(--ink);
  background: var(--bone);
  padding: 0.55em 1.6em;
  cursor: pointer;
  text-decoration: none;
  position: relative;
  transition: all 0.2s ease;
  letter-spacing: 0.08em;
  text-transform: uppercase;

  /* Engraved double-border */
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 1px var(--bone),
    inset 0 0 0 2.5px var(--ink);
}

.btn-gothic:hover {
  background: var(--ink);
  color: var(--bone);
  box-shadow:
    inset 0 0 0 1px var(--ink),
    inset 0 0 0 2.5px var(--bone);
}

.btn-gothic:active {
  transform: translateY(1px);
}

.btn-gothic:disabled,
.btn-gothic[disabled] {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-gothic:disabled:hover {
  background: var(--bone);
  color: var(--ink);
  box-shadow:
    inset 0 0 0 1px var(--bone),
    inset 0 0 0 2.5px var(--ink);
}

/* Primary / large action button */
.btn-primary {
  font-size: 1.3rem;
  padding: 0.65em 2.2em;
  border-width: 3px;
  box-shadow:
    inset 0 0 0 1.5px var(--bone),
    inset 0 0 0 3.5px var(--ink);
}

.btn-primary:hover {
  box-shadow:
    inset 0 0 0 1.5px var(--ink),
    inset 0 0 0 3.5px var(--bone);
}

/* --- Forms --- */
.form-section {
  margin-bottom: 1.8rem;
}

.section-label {
  font-family: var(--ff-gothic);
  font-size: 1.15rem;
  text-align: center;
  margin-bottom: 0.8rem;
  color: var(--ink);
}

/* Textarea — parchment scroll */
.question-input {
  width: 100%;
  min-height: 120px;
  padding: 1rem 1.2rem;
  font-family: var(--ff-body);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--ink);
  background: var(--parchment);
  border: 2px solid var(--sepia);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s;
}

.question-input::placeholder {
  color: var(--sepia-light);
  font-style: italic;
}

.question-input:focus {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}

.char-count {
  font-family: var(--ff-body);
  font-size: 0.8rem;
  color: var(--sepia-light);
  text-align: right;
  margin-top: 0.3rem;
  font-style: italic;
}

.char-count.valid {
  color: var(--sepia);
}

/* --- Radio/Option Cards — engraved selector --- */
.option-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.option-card {
  position: relative;
}

.option-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-card label {
  display: block;
  font-family: var(--ff-gothic);
  font-size: 0.95rem;
  padding: 0.5em 1.2em;
  border: 1.5px solid var(--sepia-faint);
  background: var(--bone);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  min-width: 120px;
}

.option-card label:hover {
  border-color: var(--ink);
  background: var(--parchment);
}

.option-card input:checked + label {
  border-color: var(--ink);
  border-width: 2px;
  background: var(--ink);
  color: var(--bone);
  box-shadow:
    inset 0 0 0 1px var(--ink),
    inset 0 0 0 2.5px var(--bone);
}

.option-desc {
  font-family: var(--ff-body);
  font-size: 0.75rem;
  font-style: italic;
  color: var(--sepia-light);
  margin-top: 0.15em;
  font-weight: 400;
}

.option-card input:checked + label .option-desc {
  color: var(--sepia-faint);
}

/* --- Ritual Section (Shuffle & Cut) --- */
.ritual-area {
  text-align: center;
}

.ritual-controls {
  display: flex;
  gap: 1rem;
  justify-content: center;
  align-items: center;
  margin-top: 0.8rem;
}

.shuffle-status {
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 0.9rem;
  color: var(--sepia);
  min-width: 100px;
}

.shuffle-status .count {
  font-weight: 600;
  font-style: normal;
}

/* --- Submit Area --- */
.submit-area {
  text-align: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 3px double var(--sepia);
}

/* --- Flash Messages --- */
.flash-messages {
  margin-bottom: 1.5rem;
}

.flash-msg {
  font-family: var(--ff-body);
  font-style: italic;
  color: var(--sepia);
  text-align: center;
  padding: 0.8rem 1.2rem;
  border: 1px solid var(--sepia);
  background: var(--parchment);
  margin-bottom: 0.5rem;
}

/* --- Loading State --- */
.loading .btn-primary {
  pointer-events: none;
  opacity: 0.5;
}

.loading .btn-primary::after {
  content: '...';
  animation: dots 1.5s steps(3, end) infinite;
}

@keyframes dots {
  0%, 20% { content: '.'; }
  40% { content: '..'; }
  60%, 100% { content: '...'; }
}

/* ==========================================================================
   READING PAGE
   ========================================================================== */

/* --- Reading Header --- */
.reading-header {
  text-align: center;
  margin-bottom: 2rem;
}

.reading-question {
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 1.1rem;
  color: var(--sepia);
  margin: 0.8rem 0;
  line-height: 1.5;
}

.reading-meta {
  font-family: var(--ff-body);
  font-size: 0.85rem;
  color: var(--sepia-light);
}

/* --- Card Display --- */
.card-section {
  margin-bottom: 2.5rem;
}

.card-position-name {
  font-family: var(--ff-gothic);
  font-size: 1.3rem;
  text-align: center;
  margin-bottom: 0.8rem;
  color: var(--ink);
}

.card-frame {
  max-width: 320px;
  margin: 0 auto 1.2rem;
  padding: 1.8rem 1.2rem 1.4rem;
  text-align: center;
  position: relative;
  background: var(--parchment);

  /* Gothic double frame */
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--parchment),
    inset 0 0 0 4px var(--ink),
    inset 0 0 0 7px var(--parchment),
    inset 0 0 0 8px var(--sepia-faint);
}

/* Corner marks on card frame */
.card-frame::before,
.card-frame::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
}

.card-frame::before {
  top: 8px;
  left: 8px;
  border-top: 1.5px solid var(--sepia);
  border-left: 1.5px solid var(--sepia);
}

.card-frame::after {
  bottom: 8px;
  right: 8px;
  border-bottom: 1.5px solid var(--sepia);
  border-right: 1.5px solid var(--sepia);
}

.card-name {
  font-family: var(--ff-gothic);
  font-size: 1.4rem;
  line-height: 1.2;
  margin-bottom: 0.4rem;
}

.card-orientation {
  font-family: var(--ff-body);
  font-style: italic;
  font-size: 0.85rem;
  color: var(--sepia);
}

/* Reversed card visual cue */
.card-frame.reversed {
  border-color: var(--sepia);
}

.card-frame.reversed .card-name {
  color: var(--sepia);
}

/* Card image */
.card-art {
  width: 100%;
  margin: 0.8rem 0;
  overflow: hidden;
  border: 1px solid var(--sepia-faint);
}

.card-img {
  width: 100%;
  height: auto;
  display: block;
}

.card-img-reversed {
  transform: rotate(180deg);
}

/* Cross-hatch pattern inside card (placeholder — no image) */
.card-art-placeholder {
  width: 100%;
  height: 140px;
  margin: 0.8rem 0;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--sepia-faint);
  background: var(--bone);
}

.card-art-placeholder::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 3px,
      var(--sepia-faint) 3px,
      var(--sepia-faint) 3.5px
    ),
    repeating-linear-gradient(
      -45deg,
      transparent,
      transparent 3px,
      var(--sepia-faint) 3px,
      var(--sepia-faint) 3.5px
    );
  opacity: 0.3;
}

/* Arcana symbol in the crosshatch */
.card-art-placeholder .arcana-symbol {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: var(--sepia-light);
  z-index: 1;
}

/* --- Interpretation Text --- */
.interpretation-text {
  font-family: var(--ff-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
  max-width: 600px;
  margin: 0 auto;
}

/* --- Synergies --- */
.synergies-section {
  margin: 2rem 0;
  padding: 1.2rem 1.5rem;
  border: 1px solid var(--sepia-faint);
  background: var(--parchment);
}

.synergy-note {
  font-family: var(--ff-body);
  font-style: italic;
  color: var(--sepia);
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* --- Synthesis --- */
.synthesis-section {
  margin: 2rem 0;
  padding: 1.5rem;
  border: var(--border-ornate);
  background: var(--parchment);
}

.synthesis-text {
  font-family: var(--ff-body);
  font-size: 1rem;
  line-height: 1.7;
  color: var(--sepia);
  text-align: center;
  font-style: italic;
}

/* --- AI Narrative --- */
.narrative-section {
  margin: 2.5rem 0 1rem;
  padding: 2rem 1.5rem;
  position: relative;
  background: var(--bone);
  border: 2px solid var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--bone),
    inset 0 0 0 4px var(--sepia-faint);
}

.narrative-text {
  font-family: var(--ff-body);
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  text-align: justify;
  hyphens: auto;
}

.narrative-text p {
  margin-bottom: 1rem;
}

.narrative-text p:last-child {
  margin-bottom: 0;
}

/* --- Footer / Return --- */
.reading-footer {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 3px double var(--sepia);
}

/* --- Responsive --- */
@media (max-width: 680px) {
  html { font-size: 16px; }

  .page-frame {
    margin: 1rem;
    padding: 1.5rem;
    outline-offset: 4px;
  }

  h1 { font-size: 2rem; }

  .ritual-controls {
    flex-direction: column;
    gap: 0.6rem;
  }

  .card-frame {
    max-width: 240px;
  }
}

/* ==========================================================================
   TOOLTIPS — parchment scroll on hover
   ========================================================================== */

[data-tooltip] {
  position: relative;
  cursor: help;
  border-bottom: 1px dotted var(--sepia-faint);
}

[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  top: calc(100% + 8px);
  transform: translateX(-50%);
  z-index: 100;

  font-family: var(--ff-body);
  font-size: 0.78rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.5;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  color: var(--sepia);
  background: var(--parchment);
  border: 1px solid var(--sepia-faint);
  padding: 0.5em 0.8em;
  width: max-content;
  max-width: 260px;
  white-space: normal;

  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease 0.3s;
}

[data-tooltip]:hover::after,
[data-tooltip]:focus::after {
  opacity: 1;
}

/* Buttons with tooltips — no dotted underline */
button[data-tooltip],
.btn-gothic[data-tooltip] {
  border-bottom: none;
}

/* On small screens, anchor tooltips to left */
@media (max-width: 680px) {
  [data-tooltip]::after {
    left: 0;
    transform: none;
    max-width: 220px;
  }
}

/* ==========================================================================
   SITE FOOTER
   ========================================================================== */

.site-footer {
  text-align: center;
  margin-top: 2.5rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--sepia-faint);
}

.footer-links {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.footer-links a {
  font-family: var(--ff-gothic);
  font-size: 0.7rem;
  color: var(--sepia-light);
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  transition: color 0.2s;
}

.footer-links a:hover {
  color: var(--ink);
}

.footer-copy {
  font-family: var(--ff-body);
  font-size: 0.72rem;
  color: var(--sepia-faint);
  font-style: italic;
}

.footer-credit {
  color: var(--sepia-light);
  text-decoration: none;
  border-bottom: 1px dotted var(--sepia-faint);
  transition: color 0.2s;
}

.footer-credit:hover {
  color: var(--ink);
}

/* ==========================================================================
   LEGAL / INFO PAGES
   ========================================================================== */

.legal-page h1 {
  font-size: 1.8rem;
  margin-bottom: 0.3rem;
}

.legal-page .legal-updated {
  font-family: var(--ff-body);
  font-size: 0.8rem;
  font-style: italic;
  color: var(--sepia-light);
  text-align: center;
  margin-bottom: 2rem;
}

.legal-page section {
  margin-bottom: 1.8rem;
}

.legal-page h2 {
  font-size: 1.15rem;
  text-align: left;
  margin-bottom: 0.5rem;
  letter-spacing: 0.04em;
}

.legal-page p {
  font-family: var(--ff-body);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 0.6rem;
}

.legal-page ul {
  font-family: var(--ff-body);
  font-size: 0.95rem;
  line-height: 1.7;
  color: var(--ink);
  margin: 0.4rem 0 0.8rem 1.5rem;
}

.legal-page li {
  margin-bottom: 0.25rem;
}

.legal-page .highlight-box {
  border: 1px solid var(--sepia-faint);
  background: var(--parchment);
  padding: 1rem 1.2rem;
  margin: 0.8rem 0;
}

.legal-page .back-link {
  text-align: center;
  margin-top: 2rem;
}

.legal-page .back-link a {
  font-family: var(--ff-body);
  font-size: 0.9rem;
  color: var(--sepia);
  text-decoration: none;
  border-bottom: 1px solid var(--sepia-faint);
}

.legal-page .back-link a:hover {
  color: var(--ink);
  border-color: var(--ink);
}

/* --- Print styles --- */
@media print {
  body { background: white; }
  .page-frame {
    border: 1px solid #000;
    outline: none;
    box-shadow: none;
    margin: 0;
    max-width: 100%;
  }
  .site-footer { display: none; }
}
