/* Base Styles and Reset */

/* Universal Box Sizing */
*,
*::before,
*::after {
  box-sizing: border-box;
}

/* Document */
html {
  line-height: var(--line-height-normal);
  -webkit-text-size-adjust: 100%;
  -moz-tab-size: 4;
  tab-size: 4;
}

/* Body */
body {
  font-family: var(--font-family-primary);
  background-color: var(--color-bg-primary);
  color: var(--color-text-primary);
  line-height: var(--line-height-relaxed);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* The main content takes the height a short page leaves, so the footer sits at the bottom */
#main-content {
  flex-grow: 1;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-semibold);
  margin-top: var(--space-md);
  margin-bottom: var(--space-sm);
}

/* Page and section titles carry a rule; :is keeps the element selector's specificity, so section-header-bordered still overrides it */
:is(h1, h2, h3, h4, h5, h6):where(.title:not(.is-4)) {
  border-bottom: var(--border-width-md) solid var(--color-border-primary);
  padding-bottom: var(--space-sm);
}

/* Card headers sit flush */
h3.card-header-title {
  margin: 0;
  padding: 0;
}

/* Title Classes */
.title.is-1 {
  color: var(--color-heading-primary);
  font-size: var(--font-size-5xl);
}

.title.is-2 {
  color: var(--color-heading-secondary);
  font-size: var(--font-size-4xl);
  font-weight: var(--font-weight-semibold);
}

.title.is-3 {
  color: var(--color-heading-secondary);
  font-size: var(--font-size-3xl);
}

.title.is-5 {
  font-size: var(--font-size-xl);
}

.subtitle.is-3 {
  color: var(--color-heading-tertiary);
  font-size: var(--font-size-xl);
}

/* Mobile heading size reduction for density */
@media (max-width: 768px) {
  .title.is-1 {
    font-size: var(--font-size-4xl); /* 5xl -> 4xl */
  }

  .title.is-2 {
    font-size: var(--font-size-3xl); /* 4xl -> 3xl */
  }

  .title.is-3 {
    font-size: var(--font-size-2xl); /* 3xl -> 2xl */
  }

  .title.is-5 {
    font-size: var(--font-size-lg); /* xl -> lg */
  }

  .subtitle.is-3 {
    font-size: var(--font-size-lg); /* xl -> lg */
  }

  /* Reduce default heading sizes for mobile density */
  h1 {
    font-size: var(--font-size-3xl);
  }

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

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

  h4 {
    font-size: var(--font-size-lg);
  }

  h5 {
    font-size: var(--font-size-base);
  }

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

.subtitle.is-4 {
  font-size: var(--font-size-lg);
}

/* Links */
a {
  color: var(--color-link-primary);
  text-decoration: none;
  transition: color var(--transition-normal);
}

a:hover,
a:focus {
  color: var(--color-link-hover);
  text-decoration: none;
}

/* Links that stand alone as controls keep a touch-sized target */
.content-title-link,
.action-link,
.breadcrumb a,
.award-type-link,
.author-list-item a,
.nav-sign-in {
  display: inline-flex;
  align-items: center;
  min-height: var(--size-touch-target);
}

/* Focus Styles */
button:focus,
input:focus,
summary:focus,
a:focus {
  outline: var(--border-width-md) solid var(--color-link-primary);
  outline-offset: var(--border-width-md);
}

/* Utility Classes */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* Layout Containers */
.container {
  width: 100%;
  max-width: var(--container-xl);
  margin-left: auto;
  margin-right: auto;
  padding-left: var(--space-md);
  padding-right: var(--space-md);
}

/* Mobile-first dense spacing */
@media (max-width: 768px) {
  .container {
    padding-left: 0;
    padding-right: 0;
  }
}

@media (min-width: 769px) {
  .container {
    padding-left: var(--space-xl);
    padding-right: var(--space-xl);
  }
}

.section {
  padding: var(--space-xl) var(--space-lg);
  background-color: var(--color-bg-primary);
}

/* Mobile dense section spacing */
@media (max-width: 768px) {
  .section {
    padding: var(--space-mobile-sm) var(--space-md);
  }
}

@media (min-width: 1024px) {
  .section {
    padding: var(--space-2xl) var(--space-xl);
  }
}

/* Text Utilities */
.text-secondary { color: var(--color-text-secondary); }
.text-tertiary { color: var(--color-text-tertiary); }
