/*
  Tombstone Times viewer improvements.
  This file intentionally sits on top of the original PDF-Flip CSS
  so the old working engine remains untouched.
*/

html, body {
  margin: 0;
  width: 100%;
  min-height: 100%;
  background: #211b17;
}

body {
  overflow: hidden;
  color: #f2eadf;
  background-color: #211b17;
  background-image: url('https://tombstonetimes.com/wp-content/uploads/2017/07/etsbg.gif');
  background-repeat: repeat;
  background-position: top left;
}

/* The original PDF-Flip engine paints its own viewer layer. Apply the
   Tombstone Times pattern directly to that layer so it tiles rather than
   being replaced by the engine's white background. */
#PDF1,
.pdff-container,
.pdff-container.pdff-custom-fullscreen.pdff-fullscreen {
  background-color: #211b17 !important;
  background-image: url('https://tombstonetimes.com/wp-content/uploads/2017/07/etsbg.gif') !important;
  background-repeat: repeat !important;
  background-position: top left !important;
  background-size: auto !important;
}

/* A slightly cleaner, less dated toolbar */
.pdff-ui-wrapper,
.pdff-ui-btn {
  background-color: rgba(35, 31, 28, 0.96);
}

.pdff-floating .pdff-ui-controls {
  border-radius: 12px;
  padding: 0 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
  opacity: .97;
  border: 1px solid rgba(255,255,255,.08);
}

.pdff-ui-btn {
  width: 42px;
  min-width: 42px;
  height: 48px;
  padding: 15px 6px;
  font-size: 19px !important;
}

.pdff-ui-page {
  min-width: 58px;
  height: 48px;
  padding-top: 9px;
}

.pdff-ui-page label {
  padding-top: 16px;
}

.pdff-container > .pdff-ui-next,
.pdff-container > .pdff-ui-prev {
  width: 48px;
  padding: 14px 0;
  opacity: .56;
  background-color: rgba(35,31,28,.76);
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.08);
}

.pdff-container > .pdff-ui-next:hover,
.pdff-container > .pdff-ui-prev:hover {
  opacity: .9;
}

/* More obvious keyboard focus for accessibility */
.pdff-ui-btn:focus,
.pdff-ui-page input:focus,
.tt-action-btn:focus {
  outline: 2px solid #f3cb8d;
  outline-offset: -2px;
}

/* Branding bar */
.tt-topbar {
  position: fixed;
  top: 10px;
  left: 10px;
  right: 10px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  pointer-events: none;
}

.tt-topbar-inner,
.tt-actions {
  pointer-events: auto;
}

.tt-topbar-inner {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(24, 20, 18, 0.85);
  color: #f2eadf;
  border-radius: 14px;
  padding: 10px 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.33);
  border: 1px solid rgba(255,255,255,.09);
  backdrop-filter: blur(4px);
}

.tt-brand-block {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.tt-publication {
  font-family: 'GothamRounded-Bold', Helvetica, Arial, sans-serif;
  font-size: 16px;
  letter-spacing: .03em;
}

.tt-issue {
  font-family: 'GothamRounded-Medium', Helvetica, Arial, sans-serif;
  font-size: 13px;
  color: #d7c8b4;
}

.tt-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tt-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  text-decoration: none;
  border: 1px solid rgba(255,255,255,.09);
  background: rgba(24, 20, 18, 0.87);
  color: #f2eadf;
  font-family: 'GothamRounded-Medium', Helvetica, Arial, sans-serif;
  font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.33);
  backdrop-filter: blur(4px);
}

.tt-action-btn:hover {
  background: rgba(59, 44, 29, 0.92);
}

.tt-action-btn--primary {
  background: linear-gradient(180deg, rgba(153, 104, 51, 0.96), rgba(112, 74, 37, 0.96));
  color: #fff8ed;
}

.tt-action-btn--primary:hover {
  background: linear-gradient(180deg, rgba(171, 117, 57, 0.97), rgba(128, 86, 43, 0.97));
}

/* Loading screen */
.tt-loading {
  position: fixed;
  inset: 0;
  z-index: 9998;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #161311;
  background-image: linear-gradient(rgba(18, 15, 12, 0.88), rgba(18, 15, 12, 0.94)), url('https://tombstonetimes.com/wp-content/uploads/2017/07/etsbg.gif');
  background-repeat: repeat;
  background-position: top left;
  color: #f2eadf;
  transition: opacity .35s ease, visibility .35s ease;
}

.tt-loading.tt-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.tt-loading-card {
  width: min(92vw, 440px);
  border-radius: 18px;
  padding: 24px 24px 22px;
  background: rgba(28, 23, 19, 0.92);
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: 0 14px 42px rgba(0,0,0,.45);
  text-align: center;
}

.tt-loading-kicker {
  font-family: 'GothamRounded-Bold', Helvetica, Arial, sans-serif;
  font-size: 22px;
  margin-bottom: 8px;
}

.tt-loading-issue {
  font-family: 'GothamRounded-Medium', Helvetica, Arial, sans-serif;
  font-size: 16px;
  color: #d7c8b4;
  margin-bottom: 16px;
}

.tt-loading-message {
  font-family: 'GothamRounded-Medium', Helvetica, Arial, sans-serif;
  font-size: 14px;
  color: #efe5d9;
  margin-top: 12px;
}

.tt-loading-spinner {
  width: 40px;
  height: 40px;
  margin: 0 auto;
  border-radius: 50%;
  border: 4px solid rgba(255,255,255,.18);
  border-top-color: #d2a46a;
  animation: tt-spin 1s linear infinite;
}

@keyframes tt-spin {
  to { transform: rotate(360deg); }
}

/* Keep the entire viewer inside the browser window.
   border-box is important: the header allowance is included in the 100vh,
   rather than making the viewer taller than the screen. */
#PDF1,
.pdff-container {
  width: 100%;
  height: 100vh !important;
  max-height: 100vh;
  box-sizing: border-box;
}

/* Give the top bar room on desktop without increasing total viewer height. */
.pdff-container {
  padding-top: 40px;
}

/* Mobile: larger tap targets, less clutter */
@media (max-width: 700px) {
  .tt-topbar {
    top: 6px;
    left: 6px;
    right: 6px;
    flex-direction: column;
    align-items: stretch;
  }

  .tt-topbar-inner {
    width: auto;
    justify-content: center;
    padding: 8px 12px;
  }

  .tt-actions {
    width: 100%;
    justify-content: center;
  }

  .tt-action-btn {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 10px;
    min-height: 44px;
    font-size: 13px;
  }

  .pdff-floating .pdff-ui-controls {
    bottom: 6px;
    padding: 0 4px;
    max-width: calc(100vw - 12px);
  }

  .pdff-ui-btn {
    width: 44px;
    min-width: 44px;
    height: 50px;
    padding: 16px 5px;
    font-size: 20px !important;
  }

  .pdff-ui-page {
    min-width: 52px;
    height: 50px;
  }

  .pdff-ui-start,
  .pdff-ui-end {
    display: none !important;
  }

  .pdff-container > .pdff-ui-next,
  .pdff-container > .pdff-ui-prev {
    width: 44px;
    padding: 16px 0;
    opacity: .72;
  }

  .pdff-container {
    padding-top: 88px;
  }
}

@media (max-width: 460px) {
  .tt-publication {
    font-size: 15px;
  }

  .tt-issue {
    font-size: 12px;
  }

  .pdff-ui-thumbnail {
    display: none !important;
  }

  .pdff-container {
    padding-top: 94px;
  }
}

/* Fullscreen should use every pixel of the screen. */
.pdff-container.pdff-fullscreen {
  padding-top: 0 !important;
  height: 100vh !important;
  max-height: 100vh !important;
}


/* ============================================================
   VERSION 3.7 — iPhone / small-screen refinements
   ============================================================ */

/* Dynamic viewport height follows Safari's actually visible browser area. */
#PDF1,
.pdff-container {
  height: 100vh !important; /* fallback */
  max-height: 100vh;
}

@supports (height: 100dvh) {
  #PDF1,
  .pdff-container {
    height: 100dvh !important;
    max-height: 100dvh;
  }
}

.tt-label-mobile {
  display: none;
}

@media (max-width: 700px) {
  /* Put everything in ONE compact row instead of two tall rows. */
  .tt-topbar {
    top: 4px;
    left: 4px;
    right: 4px;
    flex-direction: row;
    align-items: stretch;
    gap: 4px;
  }

  .tt-topbar-inner {
    flex: 1 1 42%;
    min-width: 0;
    padding: 5px 8px;
    border-radius: 9px;
    justify-content: center;
  }

  .tt-brand-block {
    min-width: 0;
    text-align: center;
  }

  .tt-publication {
    font-size: 12px;
    white-space: nowrap;
  }

  .tt-issue {
    font-size: 10px;
    white-space: nowrap;
  }

  .tt-actions {
    flex: 1 1 58%;
    min-width: 0;
    gap: 4px;
  }

  .tt-action-btn {
    flex: 1 1 0;
    min-width: 0;
    min-height: 38px;
    padding: 0 6px;
    border-radius: 9px;
    font-size: 11px;
    white-space: nowrap;
  }

  .tt-label-desktop {
    display: none;
  }

  .tt-label-mobile {
    display: inline;
  }

  /* Only reserve the height of the compact single-row header. */
  .pdff-container {
    padding-top: 48px !important;
  }

  /* Keep navigation useful without covering too much newspaper. */
  .pdff-container > .pdff-ui-next,
  .pdff-container > .pdff-ui-prev {
    width: 38px;
    padding: 12px 0;
    opacity: .68;
  }

  /* The bottom toolbar should remain compact on a phone. */
  .pdff-floating .pdff-ui-controls {
    bottom: 4px;
    max-width: calc(100vw - 8px);
  }

  .pdff-ui-btn {
    width: 39px;
    min-width: 39px;
    height: 44px;
    padding: 13px 4px;
    font-size: 18px !important;
  }

  .pdff-ui-page {
    min-width: 48px;
    height: 44px;
  }
}

@media (max-width: 460px) {
  .pdff-container {
    padding-top: 48px !important;
  }
}
