/* ============================================================
   Greg T Meyers — Site Enhancements
   Animations, micro-interactions, and polish
   ============================================================ */

/* ── Google Font upgrade: pair Open Sans with a serif display face ── */
@import url('https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@0,600;1,400&family=Open+Sans:wght@300;400;600&display=swap');

/* ── CSS custom properties ── */
:root {
  --gold:        #FCDD44;
  --gold-deep:   #a99300;
  --dark-bg:     #32332d;
  --dark-card:   #3e3f38;
  --text-light:  #cccccc;
  --text-muted:  #888888;
  --transition:  0.28s cubic-bezier(0.4, 0, 0.2, 1);
  --shadow-book: 8px 12px 28px rgba(0,0,0,0.55);
}

/* ── Smooth scroll ── */
html { scroll-behavior: smooth; }

/* ── Page fade-in ── */
body {
  animation: pageFadeIn 0.5s ease both;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);   }
}

/* ============================================================
   NAVIGATION — animated underline indicator
   ============================================================ */
.tm-nav li a {
  position: relative;
  transition: color var(--transition), background var(--transition);
}
.tm-nav li a::after {
  content: '';
  position: absolute;
  left: 34px;
  right: 34px;
  bottom: 10px;
  height: 2px;
  background: var(--gold);
  transform: scaleX(0);
  transition: transform var(--transition);
  transform-origin: center;
}
.tm-nav li a:hover::after,
.tm-nav li a.active::after {
  transform: scaleX(1);
}

/* ── Mobile menu smooth slide ── */
@media screen and (max-width: 767px) {
  .tm-nav {
    transition: opacity 0.3s ease, transform 0.3s ease !important;
    transform: translateY(-8px);
  }
  .tm-nav.show {
    transform: translateY(0) !important;
  }
}

/* ============================================================
   BOOK COVERS — hover lift + glow + title reveal overlay
   ============================================================ */
.tm-home-box-2 {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  transition: transform var(--transition);
}
.tm-home-box-2 a {
  display: block;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
}
.tm-home-box-2 a img {
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94),
              box-shadow 0.4s ease !important;
  display: block;
  width: 100%;
}
.tm-home-box-2 a:hover img {
  transform: translateY(-6px) scale(1.02);
  box-shadow: var(--shadow-book) !important;
}

/* Book overlay on hover */
.tm-home-box-2 a::after {
  content: attr(data-title);
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(0,0,0,0.82) 0%, rgba(0,0,0,0.15) 60%, transparent 100%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px 12px;
  color: #fff;
  font-family: 'Playfair Display', serif;
  font-size: 15px;
  font-style: italic;
  text-align: center;
  opacity: 0;
  transition: opacity 0.35s ease;
  pointer-events: none;
}
.tm-home-box-2 a:hover::after {
  opacity: 1;
}

/* ============================================================
   BUTTONS — ripple + press effect
   ============================================================ */

/* Generic button base */
button,
.tm-banner-link,
input[type="submit"] {
  position: relative;
  overflow: hidden;
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              transform 0.12s ease, box-shadow var(--transition) !important;
}

/* Press-down feel */
button:active,
.tm-banner-link:active {
  transform: scale(0.97);
}

/* Ripple effect */
button::after,
.tm-banner-link::after {
  content: '';
  position: absolute;
  inset: 50% 50% auto auto;
  width: 0; height: 0;
  background: rgba(255,255,255,0.25);
  border-radius: 50%;
  transform: translate(50%, -50%);
  transition: width 0.5s ease, height 0.5s ease, opacity 0.5s ease;
  opacity: 0;
  pointer-events: none;
}
button:active::after,
.tm-banner-link:active::after {
  width: 300px; height: 300px;
  opacity: 1;
  transition: none;
}

/* Search / Send buttons */
#aphorisms button,
#contact-form button {
  cursor: pointer;
  transition: background var(--transition), color var(--transition),
              transform 0.12s ease, box-shadow var(--transition);
}
#aphorisms button:hover {
  background: var(--gold) !important;
  color: #111 !important;
  box-shadow: 0 3px 12px rgba(252,221,68,0.4);
}
#contact-form button:hover {
  background: #888 !important;
  box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}
#aphorisms button:active,
#contact-form button:active {
  transform: scale(0.96);
}

/* ============================================================
   SOCIAL ICONS — hover bounce + color tint
   ============================================================ */
.social-icons {
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              filter var(--transition) !important;
  cursor: pointer;
}
[onclick^="shareOn"]:hover .social-icons,
[onclick^="shareOn"]:focus .social-icons {
  transform: translateY(-4px) scale(1.15);
  filter: brightness(2) !important;
}
[onclick^="shareOn"] {
  display: inline-block !important;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   SECTION HEADERS — fade-up on scroll (IntersectionObserver)
   ============================================================ */
.animate-fadeup {
  opacity: 0;
  transform: translateY(28px);
  transition: opacity 0.55s ease, transform 0.55s ease;
}
.animate-fadeup.visible {
  opacity: 1;
  transform: translateY(0);
}

/* ============================================================
   BLOG GRID — clean card layout
   ============================================================ */
.blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 28px;
  padding: 10px 0 20px;
}

.blog-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 2px 14px rgba(0,0,0,0.09);
  transition: transform var(--transition), box-shadow var(--transition);
  height: 100%;
}
.blog-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 28px rgba(0,0,0,0.15);
}

/* Fixed-height image area — keeps all cards the same height */
.blog-card-img {
  width: 100%;
  height: 190px;
  overflow: hidden;
  background: #e8e8e8;
  flex-shrink: 0;
}
.blog-card-img img {
  width: 100% !important;
  height: 100% !important;   /* override Bootstrap's .img-responsive height:auto */
  max-width: none !important; /* override Bootstrap's max-width:100% */
  object-fit: cover;
  display: block !important;
  transition: transform 0.4s ease;
}
.blog-card:hover .blog-card-img img {
  transform: scale(1.04);
}
.blog-card-img--placeholder {
  background: linear-gradient(135deg, #e0ddd5 0%, #c8c4bb 100%);
}

/* Card text body */
.blog-card-body {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 16px 18px 18px;
}
.blog-card-title {
  font-family: 'Playfair Display', serif;
  font-size: 17px;
  font-weight: 600;
  line-height: 1.35;
  margin: 0 0 8px;
  color: #222;
}
.blog-card-title a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}
.blog-card-title a:hover {
  color: var(--gold-deep);
}
.blog-card-sub {
  font-size: 13px;
  color: #666;
  line-height: 1.5;
  margin: 0 0 10px;
  flex: 1;                   /* pushes date + button to bottom */
}
.blog-card-date {
  display: block;
  font-size: 11px;
  color: #aaa;
  letter-spacing: 0.03em;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.blog-card-read {
  display: inline-block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gold-deep);
  text-decoration: none;
  transition: color var(--transition);
  margin-top: auto;
}
.blog-card-read:hover {
  color: #7a6a00;
  text-decoration: underline;
}

/* ============================================================
   APHORISM SEARCH — input focus glow
   ============================================================ */
#aphorism-search {
  transition: border-color var(--transition), box-shadow var(--transition) !important;
}
#aphorism-search:focus {
  outline: none;
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(252,221,68,0.2) !important;
}
#aphorism-topic {
  transition: border-color var(--transition), box-shadow var(--transition) !important;
}
#aphorism-topic:focus {
  outline: none;
  border-color: var(--gold) !important;
  box-shadow: 0 0 0 3px rgba(252,221,68,0.2) !important;
}

/* Aphorism frame cards — subtle hover lift */
#search-result .col-lg-3 {
  transition: transform var(--transition);
}
#search-result .col-lg-3:hover {
  transform: translateY(-4px);
}

/* Aphorism result fade-in */
#search-result {
  transition: opacity 0.4s ease;
}

/* ============================================================
   CONTACT FORM — input focus ring
   ============================================================ */
#contact-form input,
#contact-form textarea {
  transition: border-color var(--transition), box-shadow var(--transition) !important;
}
#contact-form input:focus,
#contact-form textarea:focus {
  outline: none;
  border-color: #888 !important;
  box-shadow: 0 0 0 3px rgba(150,150,150,0.2) !important;
}

/* ============================================================
   SECTION DIVIDER HRS — animated reveal
   ============================================================ */
.tm-section-header hr {
  transition: width 0.6s ease, opacity 0.6s ease;
}

/* ============================================================
   FOOTER social row — spacing consistency
   ============================================================ */
footer [onclick^="shareOn"] {
  margin: 0 4px;
}

/* ============================================================
   ABOUT PAGE — bio text gentle entrance
   ============================================================ */
.about-bio-text {
  animation: pageFadeIn 0.7s ease 0.2s both;
}

/* ============================================================
   BANNER LOGO — subtle pulse
   ============================================================ */
.tm-banner-inner img[src*="logo"] {
  animation: logoPulse 4s ease-in-out infinite;
}
@keyframes logoPulse {
  0%, 100% { filter: drop-shadow(0 0 0px rgba(252,221,68,0)); }
  50%       { filter: drop-shadow(0 0 18px rgba(252,221,68,0.45)); }
}

/* ============================================================
   "Back to top" button (injected via JS)
   ============================================================ */
#back-to-top {
  position: fixed;
  bottom: 30px;
  right: 30px;
  width: 44px;
  height: 44px;
  background: var(--gold-deep);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 20px;
  line-height: 44px;
  text-align: center;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity 0.3s ease, transform 0.3s ease, background var(--transition);
  z-index: 9999;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
}
#back-to-top.visible {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0);
}
#back-to-top:hover {
  background: var(--gold);
  color: #111;
}

/* ============================================================
   LOADING SPINNER for blog / aphorism fetch
   ============================================================ */
.gtm-spinner {
  display: inline-block;
  width: 32px; height: 32px;
  border: 3px solid rgba(252,221,68,0.25);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 20px auto;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   REDUCED MOTION — respect user preference
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ============================================================
   APHORISM CARDS — redesigned
   ============================================================ */
.aphorism-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 24px;
  padding: 8px 0 24px;
}
.aphorism-grid--single {
  grid-template-columns: minmax(240px, 400px);
  justify-content: center;
}

/* Card entrance animation */
@keyframes aphCardIn {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.aph-card {
  display: flex;
  flex-direction: column;
  border-radius: 10px;
  overflow: hidden;
  background: #22231d;
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
  animation: aphCardIn 0.45s ease both;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.aph-card:hover {
  transform: translateY(-5px);
  box-shadow: 0 12px 32px rgba(0,0,0,0.6);
}

/* Frame area */
.aph-frame {
  position: relative;
  min-height: 200px;
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px 36px;
  flex: 1;
}
/* Stronger dark overlay — key to text readability */
.aph-frame::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(10,12,8,0.72);
  border-radius: 10px 10px 0 0;
}

/* Text: non-italic, high contrast, generous spacing */
.aph-text {
  position: relative;
  z-index: 1;
  font-family: 'Open Sans', sans-serif;
  font-style: normal;
  font-weight: 300;
  font-size: 14px;
  line-height: 1.8;
  color: #f5f0e8;
  text-align: center;
  margin: 0;
  letter-spacing: 0.02em;
  text-shadow: 0 1px 6px rgba(0,0,0,0.9);
}

/* Opening quote mark */
.aph-frame::after {
  content: '“';
  position: absolute;
  top: 10px;
  left: 16px;
  font-family: Georgia, serif;
  font-size: 52px;
  line-height: 1;
  color: var(--gold);
  opacity: 0.25;
  pointer-events: none;
}

/* Action bar — centered, icon-forward */
.aph-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 12px;
  background: #1a1b16;
  border-top: 1px solid rgba(252,221,68,0.08);
}

.aph-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  background: transparent;
  color: #888880;
  cursor: pointer;
  font-size: 14px;
  text-decoration: none;
  transition: background 0.2s ease, color 0.2s ease,
              border-color 0.2s ease, transform 0.15s ease;
  padding: 0;
  flex-shrink: 0;
}
.aph-btn:hover, .aph-btn:focus {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.25);
  transform: scale(1.12);
  text-decoration: none;
  color: #e0e0e0;
}
.aph-btn:active { transform: scale(0.93); }

.aph-btn-copy:hover { color: #FCDD44; border-color: rgba(252,221,68,0.4); }
.aph-btn-tw:hover   { color: #e0e0e0; border-color: rgba(220,220,220,0.4); }
.aph-btn-fb:hover   { color: #6699dd; border-color: rgba(102,153,221,0.4); }

/* X logo character */
.x-logo {
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1;
}

/* Random button hover */
#random-btn:hover {
  background: #ffe066 !important;
  transform: scale(1.04);
}
#random-btn:active { transform: scale(0.97); }
