/* ================================================
   LICENSER.CSS — Crossed Hearts
   Covers: licenser-login, licenser-portal, licenser-reader
   Requires: style.css loaded first (uses its CSS variables)
   ================================================ */

/* ================================================
   LOGIN PAGE
   ================================================ */

.lic-login-body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

.lic-login-body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 80% 60% at 20% 10%,
      rgba(201, 168, 76, 0.05) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 60% 80% at 80% 90%,
      rgba(196, 100, 122, 0.05) 0%,
      transparent 60%
    );
  pointer-events: none;
  z-index: 0;
}

.lic-login-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 440px;
}

.lic-login-logo {
  text-align: center;
  margin-bottom: 36px;
}

.lic-login-logo-main {
  display: block;
  font-family: var(--font-d);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--cream);
}

.lic-login-logo-sub {
  display: block;
  font-family: var(--font-s);
  font-size: 10px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--rose);
  margin-top: 4px;
}

.lic-login-card {
  background: var(--ink-card);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow);
}

.lic-login-eyebrow {
  font-family: var(--font-s);
  font-size: 11px;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
  display: block;
}

.lic-login-title {
  font-family: var(--font-d);
  font-size: 32px;
  font-weight: 700;
  color: var(--cream);
  margin-bottom: 6px;
  line-height: 1.15;
}

.lic-login-title em {
  font-style: italic;
  color: var(--gold);
}

.lic-login-subtitle {
  font-family: var(--font-s);
  font-size: 15px;
  color: var(--cream-soft);
  margin-bottom: 28px;
  line-height: 1.65;
}

.lic-login-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(201, 168, 76, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 24px;
}

.lic-login-notice-icon {
  flex-shrink: 0;
  font-size: 13px;
  color: var(--gold);
}

/* Error banner — hidden by default, shown by JS */
.lic-login-error {
  background: rgba(196, 100, 122, 0.1);
  border: 1px solid rgba(196, 100, 122, 0.3);
  border-radius: var(--r);
  padding: 11px 14px;
  font-size: 13px;
  color: var(--rose);
  margin-bottom: 20px;
  display: none;
}

.lic-login-error.visible {
  display: block;
  animation: licShake 0.35s ease;
}

@keyframes licShake {
  0%,
  100% {
    transform: translateX(0);
  }
  20%,
  60% {
    transform: translateX(-5px);
  }
  40%,
  80% {
    transform: translateX(5px);
  }
}

.lic-field-hint {
  font-size: 10px;
  color: var(--muted);
  margin-top: 5px;
  letter-spacing: 0.04em;
}

.lic-field-error {
  font-size: 11px;
  color: var(--rose);
  margin-top: 5px;
  display: none;
}

.lic-field-error.visible {
  display: block;
  animation: chErrFadeIn 0.18s ease;
}

.lic-pw-wrap {
  position: relative;
}

.lic-pw-wrap .form-input {
  padding-right: 58px;
}

.form-input.err {
  border-color: var(--rose) !important;
}

.lic-pw-toggle {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-b);
  padding: 4px 6px;
  transition: color 0.2s;
}

.lic-pw-toggle:hover {
  color: var(--cream);
}

.lic-btn-submit {
  width: 100%;
  background: var(--gold);
  color: var(--ink);
  border: none;
  border-radius: var(--r);
  padding: 14px;
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.25s;
  margin-top: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.lic-btn-submit:hover:not(:disabled) {
  background: var(--gold-lt);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(201, 168, 76, 0.35);
}

.lic-btn-submit:active:not(:disabled) {
  transform: scale(0.98);
}

.lic-btn-submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lic-login-back {
  text-align: center;
  margin-top: 22px;
  font-size: 12px;
  color: var(--muted);
}

.lic-login-back a {
  color: var(--gold);
  text-decoration: none;
  transition: opacity 0.2s;
}

.lic-login-back a:hover {
  opacity: 0.7;
}

/* ================================================
   PORTAL PAGE
   ================================================ */

/* Timer pill — shared by portal and reader */
.lic-timer-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--ink-mid);
  border: 1px solid var(--border-s);
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.06em;
  user-select: none;
  transition: border-color 0.3s;
}

.lic-timer-pill.warning {
  border-color: rgba(214, 140, 60, 0.5);
}

.lic-timer-pill.danger {
  border-color: rgba(196, 100, 122, 0.6);
}

.lic-timer-dot {
  width: 6px;
  height: 6px;
  background: #4caf76;
  border-radius: 50%;
  flex-shrink: 0;
  animation: licPulse 2s ease infinite;
}

.lic-timer-dot.warning {
  background: #d6965a;
}
.lic-timer-dot.danger {
  background: var(--rose);
}

@keyframes licPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.35;
  }
}

#licTimerDisplay {
  color: var(--cream);
  font-weight: 500;
}

/* Portal nav additions */
.lic-nav-user {
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.lic-nav-user strong {
  color: var(--cream);
}

.lic-btn-signout {
  background: transparent;
  border: 1px solid rgba(196, 100, 122, 0.35);
  border-radius: var(--r);
  color: var(--rose);
  font-family: var(--font-b);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.lic-btn-signout:hover {
  background: rgba(196, 100, 122, 0.1);
}

/* Info bar */
.lic-info-bar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 64px 28px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lic-id-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(201, 168, 76, 0.06);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1em;
  color: var(--gold);
}

.lic-name-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-s);
  border-radius: 20px;
  padding: 5px 16px;
  font-size: 11px;
  color: var(--cream-soft);
}

/* Notice bar */
.lic-notice-wrap {
  max-width: 1200px;
  margin: 0 auto 32px;
  padding: 0 64px;
}

.lic-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(201, 168, 76, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 16px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.lic-notice-gold {
  color: var(--gold);
  flex-shrink: 0;
  font-size: 14px;
}

/* Grid wrapper */
.lic-grid-wrap {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 64px 80px;
}

.lic-grid-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--border-s);
  flex-wrap: wrap;
  gap: 10px;
}

.lic-grid-title {
  font-family: var(--font-d);
  font-size: clamp(22px, 3.5vw, 34px);
  font-weight: 700;
  color: var(--cream);
}

.lic-grid-title em {
  font-style: italic;
  color: var(--rose);
}

.lic-vol-count {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

/* Volume grid */
.lic-vol-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 24px;
}

/* Volume card */
.lic-vol-card {
  background: var(--ink-card);
  border: 1px solid var(--border-s);
  border-radius: var(--r-lg);
  overflow: hidden;
  cursor: pointer;
  transition: all 0.32s ease;
  display: flex;
  flex-direction: column;
  animation: fadeUp 0.5s ease both;
  position: relative;
}

.lic-vol-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--gold), var(--rose));
  opacity: 0;
  transition: opacity 0.25s;
}

.lic-vol-card:hover {
  transform: translateY(-6px);
  border-color: var(--border);
  box-shadow: var(--shadow), var(--shadow-g);
}

.lic-vol-card:hover::before {
  opacity: 1;
}

.lic-cover-wrap {
  aspect-ratio: 2/3;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ink-mid);
}

.lic-cover-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
}

.lic-cover-overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 5, 8, 0);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s;
  z-index: 2;
}

.lic-vol-card:hover .lic-cover-overlay {
  background: rgba(8, 5, 8, 0.74);
}

.lic-cover-cta {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0;
  transform: translateY(6px);
  transition:
    opacity 0.25s,
    transform 0.25s;
}

.lic-vol-card:hover .lic-cover-cta {
  opacity: 1;
  transform: translateY(0);
}

.lic-vol-type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 3;
  background: rgba(8, 5, 8, 0.85);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 3px 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}

.lic-vol-body {
  padding: 14px 16px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.lic-vol-meta {
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--rose);
  margin-bottom: 6px;
}

.lic-vol-title {
  font-family: var(--font-s);
  font-size: 14px;
  color: var(--cream);
  line-height: 1.35;
  flex: 1;
  margin-bottom: 12px;
}

.lic-vol-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 10px;
  border-top: 1px solid var(--border-s);
  gap: 8px;
}

.lic-vol-pages {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
}

.lic-btn-review {
  background: transparent;
  border: 1px solid rgba(196, 100, 122, 0.35);
  border-radius: var(--r);
  color: var(--rose);
  font-family: var(--font-b);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  padding: 6px 12px;
  cursor: pointer;
  transition: background 0.2s;
}

.lic-btn-review:hover {
  background: rgba(196, 100, 122, 0.1);
}

/* Empty state */
.lic-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 24px;
}

.lic-empty-icon {
  font-size: 36px;
  margin-bottom: 14px;
  opacity: 0.3;
}

.lic-empty-text {
  font-family: var(--font-s);
  font-size: 16px;
  color: var(--cream-soft);
  margin-bottom: 8px;
}

.lic-empty-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ================================================
   READER PAGE
   ================================================ */

.lic-reader-body-bg {
  background: #0c0c0c;
}

.read-progress {
  position: fixed;
  top: var(--nav-h);
  left: 0;
  right: 0;
  height: 3px;
  background: var(--border-s);
  z-index: 200;
}

.read-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--rose));
  transition: width 0.4s ease;
  width: 0%;
}

.reader-topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.reader-topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.reader-topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* Smaller timer dot for reader (5px vs 6px) */
.reader-topbar-right .lic-timer-dot {
  width: 5px;
  height: 5px;
}

.lic-page-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-s);
  color: var(--muted);
  width: 30px;
  height: 30px;
  border-radius: var(--r);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.lic-page-btn:hover:not(:disabled) {
  border-color: var(--gold);
  color: var(--gold);
}

.lic-page-btn:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.lic-zoom-controls {
  display: flex;
  align-items: center;
  gap: 4px;
}

.lic-zoom-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-s);
  color: var(--muted);
  width: 28px;
  height: 28px;
  font-size: 16px;
  cursor: pointer;
  border-radius: var(--r);
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lic-zoom-btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.lic-zoom-label {
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.06em;
  min-width: 36px;
  text-align: center;
}

.lic-reader-body {
  min-height: calc(100vh - var(--nav-h) - 52px);
  padding: 32px 20px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.lic-pdf-wrap {
  position: relative;
  display: inline-block;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.75);
  border: 1px solid rgba(201, 168, 76, 0.06);
  user-select: none;
  -webkit-user-select: none;
}

#licPdfCanvas {
  display: block;
  max-width: 100%;
}

/* Watermark overlay */
.lic-watermark {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 10;
  overflow: hidden;
}

.lic-wm-tile {
  position: absolute;
  transform: rotate(-35deg);
  transform-origin: center;
  pointer-events: none;
  font-family: var(--font-b);
  font-size: 11px;
  font-weight: 400;
  color: rgba(201, 168, 76, 0.11);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  line-height: 2;
  user-select: none;
  -webkit-user-select: none;
}

/* Loader */
.lic-loader {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 100px 24px;
  color: var(--muted);
}

.lic-spin {
  width: 28px;
  height: 28px;
  border: 2px solid var(--border-s);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.lic-loader-txt {
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
}

/* Error state */
.lic-error {
  display: none;
  text-align: center;
  padding: 80px 24px;
}

.lic-error h3 {
  font-family: var(--font-d);
  font-size: 24px;
  color: var(--cream);
  margin: 12px 0 8px;
}

.lic-error p {
  font-family: var(--font-s);
  font-size: 15px;
  color: var(--cream-soft);
  margin-bottom: 20px;
}

/* ================================================
   TIMEOUT MODAL — shared by portal and reader
   ================================================ */

.lic-timeout-modal {
  max-width: 420px;
  text-align: center;
}

.lic-timeout-icon {
  font-size: 40px;
  margin-bottom: 16px;
}

/* ================================================
   RESPONSIVE
   ================================================ */

@media (max-width: 1024px) {
  .lic-info-bar,
  .lic-notice-wrap,
  .lic-grid-wrap {
    padding-left: 32px;
    padding-right: 32px;
  }
}

@media (max-width: 900px) {
  .lic-timer-pill {
    display: none;
  }
}

@media (max-width: 768px) {
  .lic-info-bar,
  .lic-notice-wrap,
  .lic-grid-wrap {
    padding-left: 16px;
    padding-right: 16px;
  }

  .lic-vol-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
  }

  .lic-login-card {
    padding: 28px 20px;
  }

  .lic-zoom-controls {
    display: none;
  }

  .reader-topbar-right .reader-ch {
    display: none;
  }
}

@media (max-width: 480px) {
  .lic-vol-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .lic-login-wrap {
    max-width: 100%;
  }
}

@media print {
  body {
    display: none !important;
  }
}

/* Licenser portal navbar alignment */
.nav .lic-nav-user,
.nav .lic-timer-pill,
.nav .lic-btn-signout {
  align-self: center;
}

.nav .lic-nav-user {
  display: inline-flex;
  align-items: center;
  max-width: 260px;
  min-width: 0;
  white-space: nowrap;
}

.nav .lic-nav-user strong {
  display: inline-block;
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: bottom;
}

.nav .lic-btn-signout {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

@media (max-width: 768px) {
  .nav .lic-nav-user {
    display: none;
  }
}
