/* ================================
   Base Styles & Typography
   Andy Yen Portfolio
   ================================ */

/* ============================================
   GLOBAL STYLES
   ============================================ */

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-family-body);
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  line-height: var(--line-height-normal);
  color: var(--color-text-primary);
  background-color: var(--color-bg-primary);
  transition: var(--transition-colors);
}

/* ============================================
   TYPOGRAPHY
   ============================================ */

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-family-heading);
  font-weight: var(--font-weight-bold);
  line-height: var(--line-height-tight);
  letter-spacing: var(--letter-spacing-tight);
  color: var(--color-text-primary);
  margin-top: var(--space-8);
  margin-bottom: var(--space-5);
  overflow: visible;
  padding-bottom: var(--space-2);
}

/* First heading has no top margin */
h1:first-child,
h2:first-child,
h3:first-child,
h4:first-child,
h5:first-child,
h6:first-child {
  margin-top: 0;
}

h1 {
  font-size: var(--font-size-5xl);
  font-weight: var(--font-weight-black);
  letter-spacing: var(--letter-spacing-tighter);
  line-height: 1.15;
}

h2 {
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-bold);
  line-height: 1.3;
  letter-spacing: -0.015em;
  position: relative;
  padding-bottom: var(--space-4);
}

/* Decorative accent line under section headings */
.section h2::after,
.preview-module h2::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 60px;
  height: 4px;
  background: linear-gradient(90deg,
    var(--color-accent-primary),
    var(--color-accent-secondary),
    var(--color-accent-teal));
  border-radius: var(--radius-full);
  transition: width 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity 0.3s ease;
  box-shadow: 0 0 12px rgba(91, 159, 215, 0.4);
}

/* Extend accent line on hover */
.section:hover h2::after,
.preview-module:hover h2::after {
  width: 100px;
}

/* Optional decorative dot before heading */
h2[data-dot]::before {
  content: '•';
  color: var(--color-accent-primary);
  margin-right: var(--space-3);
  font-size: 1.2em;
}

/* Decorative brackets for headings */
h2[data-decorated]::before {
  content: '[ ';
  color: var(--color-accent-primary);
  font-weight: var(--font-weight-normal);
  margin-right: var(--space-2);
  opacity: 0.7;
}

h2[data-decorated]::after {
  content: ' ]';
  color: var(--color-accent-primary);
  font-weight: var(--font-weight-normal);
  margin-left: var(--space-2);
  opacity: 0.7;
  /* Override accent line positioning for decorated headings */
  position: static;
  width: auto;
  height: auto;
  background: none;
  border-radius: 0;
}

/* Section number decoration (optional) */
h2[data-section]::before {
  content: attr(data-section) '. ';
  color: var(--color-accent-primary);
  font-weight: var(--font-weight-semibold);
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
  margin-right: var(--space-3);
  opacity: 0.8;
}

h3 {
  font-size: var(--font-size-3xl);
  letter-spacing: -0.01em;
  line-height: 1.35;
}

h4 {
  font-size: var(--font-size-2xl);
  letter-spacing: -0.01em;
  line-height: 1.4;
}

h5 {
  font-size: var(--font-size-xl);
  line-height: 1.45;
}

h6 {
  font-size: var(--font-size-lg);
  line-height: 1.5;
}

p {
  margin-bottom: var(--space-5);
  color: var(--color-text-secondary);
  line-height: var(--line-height-relaxed);
  max-width: 70ch; /* Optimal line length for readability */
}

p:last-child {
  margin-bottom: 0;
}

/* Allow full width for paragraphs in cards */
.work-card p,
.podcast-card p,
.photo-card p {
  max-width: none;
}

a {
  color: var(--color-accent-primary);
  text-decoration: none;
  transition: var(--transition-colors);
}

a:hover {
  color: var(--color-accent-secondary);
}

a:focus-visible {
  outline: 2px solid var(--color-accent-primary);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

strong {
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
}

em {
  font-style: italic;
}

small {
  font-size: var(--font-size-sm);
}

/* ============================================
   BLOCKQUOTES & PULL QUOTES
   ============================================ */

blockquote,
.pull-quote {
  position: relative;
  margin: var(--space-8) 0;
  padding: var(--space-6) var(--space-8);
  padding-left: var(--space-10);
  border-left: 4px solid var(--color-accent-primary);
  background: linear-gradient(90deg,
    rgba(91, 159, 215, 0.05),
    transparent);
  font-size: var(--font-size-lg);
  font-style: italic;
  color: var(--color-text-primary);
  line-height: var(--line-height-relaxed);
}

blockquote::before,
.pull-quote::before {
  content: '"';
  position: absolute;
  left: var(--space-4);
  top: var(--space-3);
  font-size: var(--font-size-5xl);
  font-family: Georgia, serif;
  color: var(--color-accent-primary);
  opacity: 0.3;
  line-height: 1;
}

/* Highlighted text */
.highlight,
mark {
  background: linear-gradient(90deg,
    rgba(91, 159, 215, 0.2),
    rgba(78, 205, 196, 0.2));
  color: var(--color-text-primary);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-weight: var(--font-weight-semibold);
}

/* Callout box */
.callout {
  padding: var(--space-6);
  margin: var(--space-8) 0;
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-left: 4px solid var(--color-accent-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
}

.callout-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-bold);
  color: var(--color-accent-primary);
  margin-bottom: var(--space-3);
}

/* ============================================
   LISTS
   ============================================ */

ul, ol {
  margin-left: var(--space-6);
  margin-bottom: var(--space-4);
  color: var(--color-text-secondary);
}

ul li, ol li {
  margin-bottom: var(--space-2);
  line-height: var(--line-height-relaxed);
}

/* ============================================
   CODE & PREFORMATTED TEXT
   ============================================ */

code, pre {
  font-family: var(--font-family-mono);
  font-size: var(--font-size-sm);
}

code {
  padding: var(--space-1) var(--space-2);
  background-color: var(--color-bg-tertiary);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
}

pre {
  padding: var(--space-4);
  background-color: var(--color-bg-tertiary);
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin-bottom: var(--space-4);
}

pre code {
  padding: 0;
  background: none;
}

/* ============================================
   BLOCKQUOTES
   ============================================ */

blockquote {
  margin: var(--space-8) 0;
  padding-left: var(--space-6);
  border-left: 4px solid var(--color-accent-primary);
  font-style: italic;
  color: var(--color-text-secondary);
  font-size: var(--font-size-lg);
}

/* ============================================
   HORIZONTAL RULE
   ============================================ */

hr {
  border: none;
  height: 1px;
  background: var(--gradient-divider);
  margin: var(--space-12) 0;
}

/* ============================================
   IMAGES & MEDIA
   ============================================ */

img {
  border-radius: var(--radius-base);
}

figure {
  margin: var(--space-8) 0;
}

figcaption {
  margin-top: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--color-text-tertiary);
  font-style: italic;
  text-align: center;
}

/* ============================================
   FORMS
   ============================================ */

label {
  display: block;
  margin-bottom: var(--space-2);
  font-weight: var(--font-weight-medium);
  color: var(--color-text-primary);
  font-size: var(--font-size-sm);
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="search"],
textarea {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background-color: var(--color-bg-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  transition: var(--transition-colors), var(--transition-shadow);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="tel"]:focus,
input[type="url"]:focus,
input[type="search"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--color-accent-primary);
  box-shadow: 0 0 0 3px rgba(91, 159, 215, 0.1);
}

textarea {
  resize: vertical;
  min-height: 120px;
}

::placeholder {
  color: var(--color-text-tertiary);
  opacity: 0.7;
}

/* ============================================
   BUTTONS
   ============================================ */

button,
.button {
  display: inline-block;
  padding: var(--space-3) var(--space-6);
  background-color: var(--color-accent-primary);
  color: var(--color-text-inverse);
  border: none;
  border-radius: var(--radius-md);
  font-weight: var(--font-weight-medium);
  font-size: var(--font-size-base);
  cursor: pointer;
  transition: var(--transition-all);
  text-align: center;
}

button:hover,
.button:hover {
  background-color: var(--color-accent-secondary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

button:active,
.button:active {
  transform: translateY(0);
}

button:disabled,
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ============================================
   SELECTION
   ============================================ */

::selection {
  background-color: var(--color-accent-primary);
  color: var(--color-text-inverse);
}

::-moz-selection {
  background-color: var(--color-accent-primary);
  color: var(--color-text-inverse);
}

/* ============================================
   SCROLLBAR (Webkit)
   ============================================ */

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-secondary);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border-hover);
  border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-accent-primary);
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

.skip-link {
  position: absolute;
  top: var(--space-4);
  left: var(--space-4);
  z-index: var(--z-index-toast);
  padding: var(--space-3) var(--space-6);
  background-color: var(--color-accent-primary);
  color: var(--color-text-inverse);
  border-radius: var(--radius-md);
  transform: translateY(-200%);
  transition: var(--transition-transform);
}

.skip-link:focus {
  transform: translateY(0);
}

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

@media (max-width: 1024px) {
  html {
    font-size: 15px;
  }

  h1 {
    font-size: var(--font-size-4xl);
  }

  h2 {
    font-size: var(--font-size-3xl);
  }
}

@media (max-width: 768px) {
  html {
    font-size: 14px;
  }

  h1 {
    font-size: var(--font-size-3xl);
  }

  h2 {
    font-size: var(--font-size-2xl);
  }

  h3 {
    font-size: var(--font-size-xl);
  }
}

@media (max-width: 640px) {
  h1 {
    font-size: var(--font-size-2xl);
  }

  h2 {
    font-size: var(--font-size-xl);
  }
}

/* ============================================
   SOCIAL MEDIA ICONS
   ============================================ */

.social-icon-brand {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  transition: var(--transition-transform);
  border-radius: var(--radius-md);
  overflow: hidden;
  flex-shrink: 0;
}

.social-icon-brand:hover {
  transform: translateY(-4px) scale(1.05);
  box-shadow: var(--shadow-lg);
}

.social-icon-brand img {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 48px;
  max-height: 48px;
  object-fit: contain;
}

/* Scale up icons with extra padding to fill container */
.social-icon-brand img.icon-scale-up {
  transform: scale(1.3);
}

/* Bluesky logo specific scaling to fit container better */
.social-icon-brand img[src*="Bluesky_Logo"] {
  transform: scale(1.5);
  padding: 4px;
}

@media (max-width: 640px) {
  .social-icon-brand {
    width: 40px;
    height: 40px;
  }

  .social-icon-brand img {
    width: 100%;
    height: 100%;
    max-width: 40px;
    max-height: 40px;
  }
}

/* ============================================
   Back to Top Button
   ============================================ */

.back-to-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  width: 50px;
  height: 50px;
  background-color: var(--color-accent-primary);
  color: #ffffff;
  border: none;
  border-radius: 8px;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: all 0.3s ease;
  opacity: 0;
  visibility: hidden;
  transform: translateY(10px);
  z-index: 1000;
  line-height: 1;
}

.back-to-top.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.back-to-top:hover {
  background-color: var(--color-accent-secondary);
  transform: translateY(-3px);
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.4),
    0 0 20px rgba(91, 159, 215, 0.3);
}

.back-to-top:active {
  transform: translateY(-1px) scale(0.95);
}

@media (max-width: 768px) {
  .back-to-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 46px;
    height: 46px;
    font-size: 24px;
  }
}

@media (max-width: 640px) {
  .back-to-top {
    bottom: 1rem;
    right: 1rem;
    width: 44px;
    height: 44px;
    font-size: 22px;
  }
}

/* ============================================
   Scroll-Triggered Reveal Animations
   ============================================ */

/* Initial hidden state for scroll-reveal elements */
.scroll-reveal {
  opacity: 0;
  transform: translateY(30px);
  transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Revealed state */
.scroll-reveal.reveal {
  opacity: 1;
  transform: translateY(0);
}

/* Respect user's motion preferences */
@media (prefers-reduced-motion: reduce) {
  .scroll-reveal {
    opacity: 1;
    transform: none;
    transition: none;
  }
}

/* Simpler animation on mobile for performance */
@media (max-width: 768px) {
  .scroll-reveal {
    transform: translateY(20px);
    transition: opacity 0.4s ease, transform 0.4s ease;
  }
}
