/**
 * Theme T&B — core layout and component styles.
 *
 * @package Theme_TB
 * @since 1.0.0
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body.tb-body {
  margin: 0;
  font-family: var(--tb-font-sans);
  font-size: 1rem;
  line-height: 1.6;
  color: var(--tb-color-text);
  background: var(--tb-color-bg);
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--tb-color-primary);
  text-decoration-thickness: 1px;
  text-underline-offset: 0.15em;
}

a:hover,
a:focus {
  color: var(--tb-color-primary-dark);
}

.tb-site {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tb-site-header,
.tb-site-footer {
  background: var(--tb-color-surface);
  border-bottom: 1px solid var(--tb-color-border);
}

.tb-site-footer {
  border-bottom: 0;
  border-top: 1px solid var(--tb-color-border);
  margin-top: auto;
}

.tb-site-header__inner,
.tb-site-footer__inner {
  width: min(100% - 2rem, var(--tb-container-max));
  margin-inline: auto;
  padding-block: var(--tb-space-lg);
}

.tb-site-title {
  font-family: var(--tb-font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--tb-color-text);
  text-decoration: none;
}

.tb-skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
}

.tb-skip-link:focus {
  left: var(--tb-space-md);
  top: var(--tb-space-md);
  z-index: 100000;
  background: var(--tb-color-bg);
  color: var(--tb-color-text);
  padding: var(--tb-space-sm) var(--tb-space-md);
  border: 1px solid var(--tb-color-border);
}

main[role="main"]:not(.tb-homepage) {
  width: min(100% - 2rem, var(--tb-container-max));
  margin-inline: auto;
  padding-block: var(--tb-space-xl);
}

main.tb-homepage[role="main"] {
  width: 100%;
  max-width: none;
  margin-inline: 0;
  padding-block: 0;
}

.tb-homepage-section {
  padding-block: var(--tb-space-xl);
}

.tb-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--tb-space-md);
  margin-bottom: var(--tb-space-lg);
}

.tb-section-header__title,
.tb-archive-title,
.tb-search-title {
  margin: 0;
  font-family: var(--tb-font-display);
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.tb-section-header__link {
  font-weight: 600;
  text-decoration: none;
}

.tb-card-grid,
.tb-tools-grid,
.tb-ebooks-grid,
.tb-products-grid,
.tb-blog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--tb-space-lg);
}

.tb-card {
  background: var(--tb-color-bg);
  border: 1px solid var(--tb-color-border);
  border-radius: var(--tb-radius-lg);
  overflow: hidden;
  box-shadow: var(--tb-shadow-sm);
  transition: transform var(--tb-transition), box-shadow var(--tb-transition);
}

.tb-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--tb-shadow-md);
}

.tb-card__media {
  display: block;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: var(--tb-color-surface);
}

.tb-card__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tb-card__body {
  padding: var(--tb-space-lg);
}

.tb-card__title {
  margin: 0 0 var(--tb-space-sm);
  font-size: 1.125rem;
}

.tb-card__title a {
  color: inherit;
  text-decoration: none;
}

.tb-card__excerpt,
.tb-card__meta {
  margin: 0 0 var(--tb-space-sm);
  color: var(--tb-color-text-muted);
  font-size: 0.9375rem;
}

.tb-badge {
  display: inline-block;
  margin-bottom: var(--tb-space-sm);
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.tb-badge--featured {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.tb-badge--category {
  background: rgba(79, 70, 229, 0.12);
  color: var(--tb-color-primary-dark);
}

.tb-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.65rem 1rem;
  border-radius: var(--tb-radius-md);
  border: 1px solid transparent;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--tb-transition), color var(--tb-transition), border-color var(--tb-transition);
}

.tb-button--primary {
  background: var(--tb-color-primary);
  color: #fff;
}

.tb-button--primary:hover,
.tb-button--primary:focus {
  background: var(--tb-color-primary-dark);
  color: #fff;
}

.tb-button--secondary {
  background: transparent;
  color: var(--tb-color-primary);
  border-color: var(--tb-color-primary);
}

.tb-search-form {
  position: relative;
  max-width: 560px;
}

.tb-search-form__input,
.tb-newsletter-form__input {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--tb-color-border);
  border-radius: var(--tb-radius-md);
  background: var(--tb-color-bg);
  color: var(--tb-color-text);
}

.tb-search-form__results {
  position: absolute;
  inset-inline: 0;
  top: calc(100% + 0.5rem);
  background: var(--tb-color-bg);
  border: 1px solid var(--tb-color-border);
  border-radius: var(--tb-radius-md);
  box-shadow: var(--tb-shadow-md);
  z-index: 20;
  max-height: 320px;
  overflow: auto;
}

.tb-search-result {
  display: block;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--tb-color-border);
  text-decoration: none;
  color: inherit;
}

.tb-search-result:last-child {
  border-bottom: 0;
}

.tb-search-result__type {
  display: block;
  font-size: 0.75rem;
  color: var(--tb-color-text-muted);
}

.tb-section-hero {
  background: linear-gradient(135deg, rgba(79, 70, 229, 0.08), rgba(14, 165, 233, 0.08));
}

.tb-section-hero__title {
  margin: 0 0 var(--tb-space-sm);
  font-family: var(--tb-font-display);
  font-size: clamp(2rem, 4vw, 3rem);
}

.tb-section-hero__subtitle {
  margin: 0 0 var(--tb-space-lg);
  color: var(--tb-color-text-muted);
  max-width: 60ch;
}

.tb-section-cta,
.tb-section-newsletter {
  background: var(--tb-color-surface);
  border-block: 1px solid var(--tb-color-border);
}

.tb-newsletter-form {
  display: flex;
  flex-wrap: wrap;
  gap: var(--tb-space-sm);
  max-width: 520px;
}

.tb-admin-dashboard__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--tb-space-md);
  margin-block: var(--tb-space-lg);
}

.tb-admin-card {
  background: #fff;
  border: 1px solid #dcdcde;
  border-radius: var(--tb-radius-md);
  padding: var(--tb-space-md);
}

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
  word-wrap: normal;
}