/*
Theme Name: Bearing
Theme URI: https://davidallen.blog
Author: David Allen
Author URI: https://davidallen.blog
Description: A clean, modern, whitespace-heavy WordPress theme for mixed blog and project sites. Lightweight, responsive, with built-in dark mode and a dependency-free photo lightbox.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.5
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Text Domain: bearing
Tags: blog, portfolio, one-column, custom-colors, custom-menu, featured-images, threaded-comments, translation-ready, block-styles, dark-mode
*/

/* ------------------------------------------------------------------
   1. Design tokens
------------------------------------------------------------------ */
:root {
  --bg: #ffffff;
  --bg-soft: #f7f7f5;
  --bg-card: #ffffff;
  --fg: #1a1a1a;
  --fg-soft: #555;
  --fg-muted: #888;
  --border: #e8e8e4;
  --accent: #c8553d;
  --accent-soft: #f3d9d2;
  --link: #1a1a1a;
  --link-hover: var(--accent);
  --code-bg: #f4f4f1;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);

  --font-sans: -apple-system, BlinkMacSystemFont, "Inter", "Helvetica Neue", Arial, sans-serif;
  --font-serif: "Iowan Old Style", "Charter", Georgia, "Times New Roman", serif;
  --font-mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  --container: 720px;
  --container-wide: 1100px;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 1rem;
  --space-4: 1.5rem;
  --space-5: 2rem;
  --space-6: 3rem;
  --space-7: 5rem;

  --radius: 6px;
  --radius-lg: 12px;

  --transition: 180ms ease;
}

[data-theme="dark"] {
  --bg: #121212;
  --bg-soft: #1a1a1a;
  --bg-card: #1e1e1e;
  --fg: #e8e8e4;
  --fg-soft: #b0b0a8;
  --fg-muted: #777;
  --border: #2a2a2a;
  --accent: #e88a73;
  --accent-soft: #3a2520;
  --link: #e8e8e4;
  --code-bg: #1e1e1e;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.3);
}

/* ------------------------------------------------------------------
   2. Reset & base
------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--transition), color var(--transition);
}

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

a {
  color: var(--link);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition);
}
a:hover { color: var(--link-hover); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-sans);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: -0.01em;
  margin: 0 0 var(--space-3);
}
h1 { font-size: clamp(2rem, 4vw, 2.75rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.5rem, 3vw, 1.875rem); margin-top: var(--space-6); }
h3 { font-size: 1.375rem; margin-top: var(--space-5); }
h4 { font-size: 1.125rem; }

p { margin: 0 0 var(--space-3); }

blockquote {
  margin: var(--space-5) 0;
  padding: 0 0 0 var(--space-4);
  border-left: 3px solid var(--accent);
  color: var(--fg-soft);
  font-style: italic;
}

hr {
  border: 0;
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
}
pre {
  background: var(--code-bg);
  padding: var(--space-4);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.9rem;
  line-height: 1.55;
}
pre code { background: none; padding: 0; }

::selection { background: var(--accent-soft); color: var(--fg); }

/* Skip link for accessibility */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--fg);
  color: var(--bg);
  padding: var(--space-2) var(--space-3);
  z-index: 100;
}
.skip-link:focus { left: var(--space-3); top: var(--space-3); }

/* ------------------------------------------------------------------
   3. Layout
------------------------------------------------------------------ */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 var(--space-4);
}
.container-wide {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 var(--space-4);
}

.site-main { padding: var(--space-6) 0 var(--space-7); }

/* ------------------------------------------------------------------
   4. Site header
------------------------------------------------------------------ */
.site-header {
  border-bottom: 1px solid var(--border);
  padding: var(--space-4) 0;
  background: var(--bg);
}
.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}
.site-branding { display: flex; flex-direction: column; }
.site-title {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.site-title a { text-decoration: none; }
.site-description {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  margin: 0;
}

/* Primary nav */
.primary-nav { display: flex; align-items: center; gap: var(--space-4); }
.primary-nav ul {
  list-style: none;
  display: flex;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
}
.primary-nav a {
  font-family: var(--font-sans);
  font-size: 0.95rem;
  text-decoration: none;
  color: var(--fg-soft);
}
.primary-nav a:hover,
.primary-nav .current-menu-item a { color: var(--accent); }

/* Theme toggle */
.theme-toggle {
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color var(--transition), border-color var(--transition);
}
.theme-toggle:hover { background: var(--bg-soft); border-color: var(--fg-muted); }
.theme-toggle svg { width: 18px; height: 18px; }
.theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* Mobile nav toggle */
.menu-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  color: var(--fg);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
}

@media (max-width: 640px) {
  .menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .primary-nav ul {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    padding: var(--space-3) var(--space-4);
    gap: var(--space-3);
    z-index: 10;
  }
  .primary-nav.is-open ul { display: flex; }
  .site-header { position: relative; }
}

/* ------------------------------------------------------------------
   5. Posts: list & single
------------------------------------------------------------------ */
.post-list { display: flex; flex-direction: column; gap: var(--space-6); }
.post-card { display: flex; flex-direction: column; gap: var(--space-2); }
.post-card-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.post-card-title {
  margin: 0;
  font-size: 1.5rem;
}
.post-card-title a { text-decoration: none; }
.post-card-title a:hover { color: var(--accent); }
.post-card-excerpt { color: var(--fg-soft); }
.post-card-thumb {
  margin-bottom: var(--space-3);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.post-card-thumb img { transition: transform 400ms ease; }
.post-card-thumb a:hover img { transform: scale(1.02); }

/* Single post */
.entry-header { margin-bottom: var(--space-5); text-align: center; }
.entry-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-2);
}
.entry-title { margin: 0 0 var(--space-3); }
.entry-thumbnail {
  margin: 0 calc(-1 * var(--space-4)) var(--space-5);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
@media (min-width: 720px) {
  .entry-thumbnail { margin-left: 0; margin-right: 0; }
}

.entry-content > * { margin-left: auto; margin-right: auto; }
.entry-content figure,
.entry-content .wp-block-image,
.entry-content .wp-block-gallery {
  margin: var(--space-5) 0;
}
.entry-content figcaption {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--fg-muted);
  text-align: center;
  margin-top: var(--space-2);
}

.entry-tags {
  margin-top: var(--space-6);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--fg-muted);
}
.entry-tags a {
  color: var(--fg-soft);
  text-decoration: none;
  margin-right: var(--space-2);
}
.entry-tags a:hover { color: var(--accent); }

/* Post navigation */
.post-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-4);
  margin-top: var(--space-6);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.post-nav a {
  display: block;
  text-decoration: none;
  font-family: var(--font-sans);
}
.post-nav-label {
  font-size: 0.8rem;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-1);
}
.post-nav-title { font-weight: 600; }
.post-nav .next { text-align: right; }
@media (max-width: 600px) {
  .post-nav { grid-template-columns: 1fr; }
  .post-nav .next { text-align: left; }
}

/* ------------------------------------------------------------------
   6. Projects archive (custom layout)
------------------------------------------------------------------ */
.projects-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-5);
}
.project-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
}
.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}
.project-card-thumb { aspect-ratio: 16 / 10; background: var(--bg-soft); overflow: hidden; }
.project-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.project-card-body { padding: var(--space-4); }
.project-card-title {
  font-family: var(--font-sans);
  font-size: 1.125rem;
  margin: 0 0 var(--space-2);
}
.project-card-title a { text-decoration: none; }
.project-card-excerpt {
  color: var(--fg-soft);
  font-size: 0.95rem;
  margin: 0;
}

/* ------------------------------------------------------------------
   7. Pagination
------------------------------------------------------------------ */
.pagination {
  margin-top: var(--space-7);
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  font-family: var(--font-sans);
  font-size: 0.95rem;
}
.pagination .page-numbers {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-decoration: none;
  color: var(--fg-soft);
  min-width: 38px;
  text-align: center;
}
.pagination .page-numbers:hover { border-color: var(--accent); color: var(--accent); }
.pagination .current {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* ------------------------------------------------------------------
   8. Galleries & lightbox
------------------------------------------------------------------ */
.wp-block-gallery,
.bearing-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space-2);
}
.wp-block-gallery .wp-block-image,
.bearing-gallery figure {
  margin: 0;
  border-radius: var(--radius);
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: var(--bg-soft);
}
.wp-block-gallery img,
.bearing-gallery img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  cursor: zoom-in;
  transition: transform 300ms ease;
}
.wp-block-gallery img:hover,
.bearing-gallery img:hover { transform: scale(1.04); }

/* Lightbox */
.bearing-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  cursor: zoom-out;
  padding: var(--space-5);
}
.bearing-lightbox.is-open { display: flex; }
.bearing-lightbox img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: var(--radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.bearing-lightbox-caption {
  position: absolute;
  bottom: var(--space-4);
  left: 0;
  right: 0;
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  font-family: var(--font-sans);
  font-size: 0.9rem;
}
.bearing-lightbox-close,
.bearing-lightbox-prev,
.bearing-lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.bearing-lightbox-close:hover,
.bearing-lightbox-prev:hover,
.bearing-lightbox-next:hover { background: rgba(255, 255, 255, 0.25); }
.bearing-lightbox-close { top: var(--space-4); right: var(--space-4); }
.bearing-lightbox-prev { left: var(--space-4); top: 50%; transform: translateY(-50%); }
.bearing-lightbox-next { right: var(--space-4); top: 50%; transform: translateY(-50%); }

/* ------------------------------------------------------------------
   9. Comments
------------------------------------------------------------------ */
.comments-area {
  margin-top: var(--space-7);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border);
}
.comments-title { font-size: 1.25rem; }
.comment-list { list-style: none; padding: 0; }
.comment-list ol { list-style: none; padding-left: var(--space-4); }
.comment-body {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border);
}
.comment-author { font-family: var(--font-sans); font-weight: 600; }
.comment-meta { font-size: 0.85rem; color: var(--fg-muted); margin-bottom: var(--space-2); }

.comment-form label { display: block; font-family: var(--font-sans); font-size: 0.9rem; margin-bottom: var(--space-1); }
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--fg);
  font: inherit;
  margin-bottom: var(--space-3);
}
.comment-form input:focus,
.comment-form textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.comment-form .submit,
.btn {
  background: var(--fg);
  color: var(--bg);
  border: none;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.comment-form .submit:hover,
.btn:hover { background: var(--accent); color: #fff; }

/* ------------------------------------------------------------------
   10. Footer
------------------------------------------------------------------ */
.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-5) 0;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--fg-muted);
  text-align: center;
}
.site-footer a { color: var(--fg-soft); text-decoration: none; }
.site-footer a:hover { color: var(--accent); }

/* ------------------------------------------------------------------
   11. Misc utilities
------------------------------------------------------------------ */
.alignwide { max-width: var(--container-wide); margin-left: auto; margin-right: auto; }
.alignfull { max-width: 100vw; margin-left: calc(50% - 50vw); margin-right: calc(50% - 50vw); }

.screen-reader-text {
  border: 0;
  clip: rect(1px, 1px, 1px, 1px);
  height: 1px;
  width: 1px;
  overflow: hidden;
  position: absolute !important;
  word-wrap: normal !important;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
  html { scroll-behavior: auto; }
}
