/* =====================================================
   QuickTech Blog Restyle - Realistic Animation & Human Design
   ===================================================== */

:root {
  --qtr-bg: #f5f7fa;
  --qtr-surface: #ffffff;
  --qtr-surface-warm: #f0f4f8;
  --qtr-ink: #111827;
  --qtr-muted: #6b7280;
  --qtr-accent: #0e7490;
  --qtr-accent-hover: #155e75;
  --qtr-accent-weak: color-mix(in oklab, var(--qtr-accent) 8%, var(--qtr-surface));
  --qtr-line: color-mix(in oklab, var(--qtr-ink) 8%, transparent);
  --qtr-shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
  --qtr-shadow: 0 4px 6px -1px rgba(0,0,0,0.05), 0 2px 4px -2px rgba(0,0,0,0.03);
  --qtr-shadow-lg: 0 20px 25px -5px rgba(0,0,0,0.07), 0 8px 10px -6px rgba(0,0,0,0.02);
  --qtr-shadow-xl: 0 25px 50px -12px rgba(0,0,0,0.12);

  --step--1: clamp(0.875rem, 0.85rem + 0.15vw, 0.9375rem);
  --step-0: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --step-1: clamp(1.125rem, 1rem + 0.6vw, 1.375rem);
  --step-2: clamp(1.5rem, 1.2rem + 1.5vw, 2.25rem);
  --step-3: clamp(2rem, 1.4rem + 3vw, 3.5rem);

  --space-xs: clamp(0.5rem, 0.4rem + 0.5vw, 0.75rem);
  --space-sm: clamp(0.75rem, 0.6rem + 0.75vw, 1rem);
  --space: clamp(1rem, 0.8rem + 1vw, 1.5rem);
  --space-md: clamp(1.5rem, 1.2rem + 1.5vw, 2.5rem);
  --space-lg: clamp(2.5rem, 2rem + 2.5vw, 4rem);
  --space-xl: clamp(4rem, 3rem + 5vw, 7rem);

  --radius: 16px;
  --radius-sm: 10px;
}

/* -----------------------------------------------------
   BASE RESET (scoped to qtr-active)
   ----------------------------------------------------- */
body.qtr-active {
  font-family: "Inter", "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  font-size: var(--step-0);
  line-height: 1.65;
  color: var(--qtr-ink);
  background: var(--qtr-bg);
  overflow-x: hidden;
}

body.qtr-active * {
  box-sizing: border-box;
}

body.qtr-active h1,
body.qtr-active h2,
body.qtr-active h3,
body.qtr-active h4,
body.qtr-active h5,
body.qtr-active h6 {
  font-family: "Space Grotesk", "Hiragino Sans", sans-serif;
  line-height: 1.15;
  letter-spacing: -0.02em;
  margin: 0;
}

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

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

/* -----------------------------------------------------
   HEADER - Glass Morphism Sticky
   ----------------------------------------------------- */
body.qtr-active .qtr-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.75);
  backdrop-filter: blur(16px) saturate(1.4);
  -webkit-backdrop-filter: blur(16px) saturate(1.4);
  border-bottom: 1px solid var(--qtr-line);
  transition: box-shadow 0.4s ease, background 0.4s ease;
}

body.qtr-active .qtr-header.scrolled {
  box-shadow: 0 4px 20px -4px rgba(0,0,0,0.08);
  background: rgba(255,255,255,0.92);
}

body.qtr-active .qtr-header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-sm) var(--space);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
}

body.qtr-active .qtr-logo {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: var(--step-1);
  letter-spacing: -0.03em;
  color: var(--qtr-ink);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.qtr-active .qtr-logo:hover {
  transform: scale(1.03);
}

body.qtr-active .qtr-logo-mark {
  width: 34px;
  height: 34px;
  background: var(--qtr-accent);
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.85em;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(14,116,144,0.3);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

body.qtr-active .qtr-logo:hover .qtr-logo-mark {
  transform: rotate(-8deg) scale(1.08);
  box-shadow: 0 4px 16px rgba(14,116,144,0.4);
}

body.qtr-active .qtr-nav-links {
  display: flex;
  gap: var(--space-md);
  list-style: none;
  margin: 0;
  padding: 0;
}

body.qtr-active .qtr-nav-links a {
  text-decoration: none;
  color: var(--qtr-muted);
  font-weight: 500;
  font-size: var(--step--1);
  transition: color 0.25s ease;
  position: relative;
  padding: 0.25rem 0;
}

body.qtr-active .qtr-nav-links a::after {
  content: "";
  position: absolute;
  bottom: -2px;
  left: 50%;
  width: 0;
  height: 2px;
  background: var(--qtr-accent);
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), left 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  border-radius: 1px;
}

body.qtr-active .qtr-nav-links a:hover,
body.qtr-active .qtr-nav-links a:focus-visible {
  color: var(--qtr-accent);
  outline: none;
}

body.qtr-active .qtr-nav-links a:hover::after,
body.qtr-active .qtr-nav-links a:focus-visible::after {
  width: 100%;
  left: 0;
}

/* -----------------------------------------------------
   HERO SECTION with Particle Canvas
   ----------------------------------------------------- */
body.qtr-active .qtr-hero {
  position: relative;
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-xl) var(--space) var(--space-lg);
  overflow: hidden;
}

body.qtr-active .qtr-particle-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  opacity: 0.5;
  pointer-events: none;
}

body.qtr-active .qtr-hero-content {
  position: relative;
  z-index: 1;
}

body.qtr-active .qtr-hero-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: var(--step--1);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--qtr-accent);
  margin-bottom: var(--space-sm);
  opacity: 0;
  transform: translateY(12px);
  animation: qtr-fade-up 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
}

body.qtr-active .qtr-hero-eyebrow::before {
  content: "";
  display: inline-block;
  width: 28px;
  height: 3px;
  background: var(--qtr-accent);
  border-radius: 2px;
  animation: qtr-line-grow 0.6s cubic-bezier(0.22, 1, 0.36, 1) 0.4s both;
}

body.qtr-active .qtr-hero-title {
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.035em;
  max-width: 18ch;
  margin-bottom: var(--space-sm);
  min-height: 1.2em;
}

body.qtr-active .qtr-hero-title .qtr-char {
  display: inline-block;
  opacity: 0;
  transform: translateY(20px) rotateX(-40deg);
  animation: qtr-char-reveal 0.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

body.qtr-active .qtr-hero-desc {
  color: var(--qtr-muted);
  max-width: 52ch;
  font-size: var(--step-1);
  line-height: 1.55;
  opacity: 0;
  transform: translateY(16px);
  animation: qtr-fade-up 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.9s forwards;
}

/* -----------------------------------------------------
   FEATURED POST CARD
   ----------------------------------------------------- */
body.qtr-active .qtr-featured {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space) var(--space-lg);
}

body.qtr-active .qtr-featured-card {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 0;
  background: var(--qtr-surface);
  border-radius: var(--radius);
  border: 1px solid var(--qtr-line);
  overflow: hidden;
  box-shadow: var(--qtr-shadow-lg);
  transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.5s cubic-bezier(0.22, 1, 0.36, 1);
  opacity: 0;
  transform: translateY(40px) scale(0.98);
}

body.qtr-active .qtr-featured-card.qtr-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

body.qtr-active .qtr-featured-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--qtr-shadow-xl);
}

body.qtr-active .qtr-featured-visual {
  background: linear-gradient(135deg, #0e7490 0%, #164e63 50%, #0f172a 100%);
  display: grid;
  place-items: center;
  position: relative;
  min-height: 300px;
  overflow: hidden;
}

body.qtr-active .qtr-featured-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 20% 80%, rgba(255,255,255,0.1) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(255,255,255,0.06) 0%, transparent 40%);
  animation: qtr-shimmer 8s ease-in-out infinite;
}

body.qtr-active .qtr-featured-visual::after {
  content: "";
  position: absolute;
  inset: -50%;
  background: conic-gradient(from 0deg, transparent, rgba(255,255,255,0.03), transparent 30%);
  animation: qtr-rotate-slow 20s linear infinite;
}

body.qtr-active .qtr-featured-icon {
  position: relative;
  z-index: 2;
  width: 90px;
  height: 90px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border-radius: 22px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255,255,255,0.12);
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.qtr-active .qtr-featured-card:hover .qtr-featured-icon {
  transform: scale(1.1) rotate(-5deg);
}

body.qtr-active .qtr-featured-icon svg {
  width: 44px;
  height: 44px;
  stroke: #fff;
  stroke-width: 1.5;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.qtr-active .qtr-featured-content {
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  justify-content: center;
}

body.qtr-active .qtr-featured-label {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--qtr-accent);
  margin-bottom: var(--space-xs);
}

body.qtr-active .qtr-featured-label .qtr-dot {
  width: 8px;
  height: 8px;
  background: var(--qtr-accent);
  border-radius: 50%;
  animation: qtr-pulse-glow 2.5s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(14,116,144,0.4);
}

body.qtr-active .qtr-featured-title {
  font-size: var(--step-2);
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin-bottom: var(--space-xs);
  text-decoration: none;
  color: var(--qtr-ink);
  display: block;
  transition: color 0.25s ease;
  position: relative;
}

body.qtr-active .qtr-featured-title:hover,
body.qtr-active .qtr-featured-title:focus-visible {
  color: var(--qtr-accent);
  outline: none;
}

body.qtr-active .qtr-featured-excerpt {
  color: var(--qtr-muted);
  margin-bottom: var(--space-sm);
  line-height: 1.65;
}

body.qtr-active .qtr-meta {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  font-size: var(--step--1);
  color: var(--qtr-muted);
  flex-wrap: wrap;
}

body.qtr-active .qtr-meta-sep {
  width: 4px;
  height: 4px;
  background: var(--qtr-muted);
  border-radius: 50%;
  opacity: 0.4;
}

body.qtr-active .qtr-author-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 500;
  color: var(--qtr-ink);
}

body.qtr-active .qtr-author-badge::before {
  content: "";
  width: 22px;
  height: 22px;
  background: var(--qtr-surface-warm);
  border-radius: 50%;
  border: 1px solid var(--qtr-line);
}

/* -----------------------------------------------------
   SECTION HEADER
   ----------------------------------------------------- */
body.qtr-active .qtr-section-header {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space-lg) var(--space) var(--space);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space);
}

body.qtr-active .qtr-section-title {
  font-size: var(--step-2);
  font-weight: 700;
  letter-spacing: -0.02em;
  position: relative;
  display: inline-block;
}

body.qtr-active .qtr-section-title::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 0;
  width: 40px;
  height: 3px;
  background: var(--qtr-accent);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.22, 1, 0.36, 1);
}

body.qtr-active .qtr-section-header.qtr-visible .qtr-section-title::after {
  width: 60px;
}

body.qtr-active .qtr-section-count {
  font-size: var(--step--1);
  color: var(--qtr-muted);
  font-weight: 500;
  font-family: "Space Grotesk", sans-serif;
}

/* -----------------------------------------------------
   ARTICLE GRID & CARDS with Magnetic Hover
   ----------------------------------------------------- */
body.qtr-active .qtr-article-grid {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 var(--space) var(--space-xl);
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: var(--space);
}

body.qtr-active .qtr-article-card {
  background: var(--qtr-surface);
  border-radius: var(--radius);
  border: 1px solid var(--qtr-line);
  padding: var(--space);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  position: relative;
  transition: transform 0.4s cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 0.4s cubic-bezier(0.22, 1, 0.36, 1);
  box-shadow: var(--qtr-shadow-sm);
  opacity: 0;
  transform: translateY(30px);
}

body.qtr-active .qtr-article-card.qtr-visible {
  opacity: 1;
  transform: translateY(0);
}

body.qtr-active .qtr-article-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--qtr-accent);
  border-radius: var(--radius) 0 0 var(--radius);
  opacity: 0;
  transition: opacity 0.3s ease, width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

body.qtr-active .qtr-article-card:hover::before,
body.qtr-active .qtr-article-card:focus-within::before {
  opacity: 1;
  width: 5px;
}

body.qtr-active .qtr-article-card:hover,
body.qtr-active .qtr-article-card:focus-within {
  box-shadow: var(--qtr-shadow-xl);
}

body.qtr-active .qtr-card-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
  color: var(--qtr-accent);
  margin-bottom: 0.2rem;
  font-family: "Space Grotesk", sans-serif;
}

body.qtr-active .qtr-card-title {
  font-size: var(--step-1);
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  text-decoration: none;
  color: var(--qtr-ink);
  transition: color 0.25s ease;
  margin-bottom: 0.2rem;
  position: relative;
  z-index: 2;
}

body.qtr-active .qtr-card-title:hover,
body.qtr-active .qtr-card-title:focus-visible {
  color: var(--qtr-accent);
  outline: none;
}

body.qtr-active .qtr-card-excerpt {
  color: var(--qtr-muted);
  font-size: var(--step--1);
  line-height: 1.65;
  flex-grow: 1;
}

body.qtr-active .qtr-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.4rem;
  padding-top: var(--space-xs);
  border-top: 1px solid var(--qtr-line);
  position: relative;
  z-index: 2;
}

body.qtr-active .qtr-read-time {
  font-size: 0.75rem;
  color: var(--qtr-muted);
  font-weight: 500;
}

body.qtr-active .qtr-read-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--qtr-accent);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  transition: gap 0.25s ease, color 0.25s ease;
  position: relative;
  z-index: 2;
}

body.qtr-active .qtr-read-link:hover,
body.qtr-active .qtr-read-link:focus-visible {
  gap: 0.55rem;
  color: var(--qtr-accent-hover);
  outline: none;
}

/* Card floating particles on hover */
body.qtr-active .qtr-article-card .qtr-card-sparkle {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--qtr-accent);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}

body.qtr-active .qtr-article-card:hover .qtr-card-sparkle {
  animation: qtr-sparkle-float 1.2s ease-out forwards;
}

/* -----------------------------------------------------
   FOOTER
   ----------------------------------------------------- */
body.qtr-active .qtr-footer {
  border-top: 1px solid var(--qtr-line);
  background: var(--qtr-surface);
}

body.qtr-active .qtr-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--space) var(--space);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space);
  flex-wrap: wrap;
}

body.qtr-active .qtr-footer-copy {
  font-size: var(--step--1);
  color: var(--qtr-muted);
  margin: 0;
}

body.qtr-active .qtr-footer-links {
  display: flex;
  gap: var(--space-sm);
  list-style: none;
  margin: 0;
  padding: 0;
}

body.qtr-active .qtr-footer-links a {
  font-size: var(--step--1);
  color: var(--qtr-muted);
  text-decoration: none;
  transition: color 0.2s ease;
  position: relative;
}

body.qtr-active .qtr-footer-links a:hover,
body.qtr-active .qtr-footer-links a:focus-visible {
  color: var(--qtr-accent);
  outline: none;
}

/* -----------------------------------------------------
   KEYFRAME ANIMATIONS
   ----------------------------------------------------- */
@keyframes qtr-fade-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes qtr-char-reveal {
  from {
    opacity: 0;
    transform: translateY(20px) rotateX(-40deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

@keyframes qtr-line-grow {
  from { width: 0; }
  to { width: 28px; }
}

@keyframes qtr-pulse-glow {
  0%, 100% {
    opacity: 1;
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(14,116,144,0.4);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.85);
    box-shadow: 0 0 0 8px rgba(14,116,144,0);
  }
}

@keyframes qtr-shimmer {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 0.8; }
}

@keyframes qtr-rotate-slow {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

@keyframes qtr-sparkle-float {
  0% {
    opacity: 1;
    transform: translate(0, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--sparkle-x, 20px), var(--sparkle-y, -30px)) scale(0);
  }
}

/* -----------------------------------------------------
   ACCESSIBILITY
   ----------------------------------------------------- */
body.qtr-active :focus-visible {
  outline: 2px solid var(--qtr-accent);
  outline-offset: 3px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  body.qtr-active .qtr-hero-eyebrow,
  body.qtr-active .qtr-hero-title .qtr-char,
  body.qtr-active .qtr-hero-desc,
  body.qtr-active .qtr-featured-card,
  body.qtr-active .qtr-article-card {
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }

  body.qtr-active .qtr-featured-visual::after,
  body.qtr-active .qtr-featured-label .qtr-dot,
  body.qtr-active .qtr-featured-visual::before {
    animation: none !important;
  }
}

/* -----------------------------------------------------
   RESPONSIVE
   ----------------------------------------------------- */
@media (max-width: 800px) {
  body.qtr-active .qtr-featured-card {
    grid-template-columns: 1fr;
  }
  body.qtr-active .qtr-featured-visual {
    min-height: 200px;
  }
  body.qtr-active .qtr-article-grid {
    grid-template-columns: 1fr;
  }
  body.qtr-active .qtr-nav-links {
    display: none;
  }
  body.qtr-active .qtr-section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }
  body.qtr-active .qtr-footer-inner {
    flex-direction: column;
    text-align: center;
  }
  body.qtr-active .qtr-hero-title {
    font-size: clamp(1.75rem, 1.2rem + 2.5vw, 2.5rem);
  }
}

/* -----------------------------------------------------
   PRINT
   ----------------------------------------------------- */
@media print {
  body.qtr-active {
    background: #fff !important;
  }
  body.qtr-active .qtr-header,
  body.qtr-active .qtr-footer,
  body.qtr-active .qtr-particle-canvas {
    display: none !important;
  }
  body.qtr-active .qtr-featured-card,
  body.qtr-active .qtr-article-card {
    box-shadow: none !important;
    border: 1px solid #ccc !important;
    break-inside: avoid;
  }
}
