/*
Theme Name: Old Glory
Theme URI: https://example.com/old-glory
Author: Old Glory Theme
Author URI: https://example.com
Description: A dignified, flag-forward WordPress theme celebrating the United States. Built on the official Old Glory Red and Old Glory Blue, WPA-poster slab headlines, and Public Sans (the U.S. federal government typeface). Fully responsive, accessible, and translation ready.
Version: 1.0.0
Requires at least: 6.0
Tested up to: 6.6
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: old-glory
Tags: patriotic, blog, news, custom-logo, custom-menu, featured-images, threaded-comments, translation-ready, right-sidebar, two-columns, block-styles, wide-blocks, accessibility-ready
*/

/* ==========================================================================
   1. Design tokens
   ========================================================================== */
:root {
  /* Official U.S. flag colors */
  --og-blue: #0a3161;      /* Old Glory Blue */
  --og-red: #b31942;       /* Old Glory Red */
  --og-navy-ink: #10233f;  /* deep text navy */
  --og-white: #ffffff;
  --og-bunting: #f7f4ec;   /* warm off-white, aged cotton */
  --og-gild: #b8862f;      /* brass / civic seal gold */
  --og-gild-soft: #d8b25c;
  --og-slate: #4a5a70;     /* muted supporting text */
  --og-line: #d9d3c4;      /* hairline on bunting */
  --og-blue-deep: #071f3f;

  --og-maxw: 74rem;
  --og-content: 42rem;
  --og-radius: 3px;
  --og-gap: clamp(1rem, 3vw, 2rem);

  --og-font-body: "Public Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --og-font-display: "Zilla Slab", Georgia, "Times New Roman", serif;

  --og-shadow: 0 1px 0 var(--og-line), 0 14px 30px -18px rgba(10, 49, 97, 0.45);
}

/* ==========================================================================
   2. Reset / base
   ========================================================================== */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--og-bunting);
  color: var(--og-navy-ink);
  font-family: var(--og-font-body);
  font-size: 1.0625rem;
  line-height: 1.7;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

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

a { color: var(--og-red); text-underline-offset: 0.15em; }
a:hover, a:focus { color: var(--og-blue); }

h1, h2, h3, h4, h5, h6 {
  font-family: var(--og-font-display);
  color: var(--og-blue);
  line-height: 1.12;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 0.5em;
}

h1 { font-size: clamp(2rem, 5vw, 3.25rem); }
h2 { font-size: clamp(1.6rem, 3.5vw, 2.35rem); }
h3 { font-size: clamp(1.3rem, 2.6vw, 1.7rem); }
h4 { font-size: 1.2rem; }

p { margin: 0 0 1.25rem; }

blockquote {
  margin: 1.75rem 0;
  padding: 0.4rem 0 0.4rem 1.5rem;
  border-left: 4px solid var(--og-red);
  font-family: var(--og-font-display);
  font-size: 1.3rem;
  font-style: italic;
  color: var(--og-blue);
}

code, pre {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Code", Menlo, Consolas, monospace;
  font-size: 0.9em;
}
pre {
  background: var(--og-blue-deep);
  color: var(--og-bunting);
  padding: 1.25rem;
  border-radius: var(--og-radius);
  overflow-x: auto;
}
code { background: rgba(10, 49, 97, 0.08); padding: 0.1em 0.35em; border-radius: 2px; }
pre code { background: none; padding: 0; }

hr { border: 0; height: 1px; background: var(--og-line); margin: 2.5rem 0; }

/* ==========================================================================
   3. Layout helpers
   ========================================================================== */
.og-container {
  width: min(100% - 2.5rem, var(--og-maxw));
  margin-inline: auto;
}

.og-site { overflow-clip-margin: content-box; }

.og-main { padding-block: clamp(2.5rem, 6vw, 4.5rem); }

.og-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(2rem, 5vw, 3.5rem);
}
@media (min-width: 60rem) {
  .og-layout.has-sidebar { grid-template-columns: minmax(0, 1fr) 18rem; }
}

/* Accessibility: skip link + screen reader text */
.screen-reader-text {
  border: 0; clip: rect(1px, 1px, 1px, 1px);
  clip-path: inset(50%);
  height: 1px; width: 1px; margin: -1px; padding: 0;
  overflow: hidden; position: absolute !important; word-wrap: normal !important;
}
.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100000;
  background: var(--og-red); color: #fff; padding: 0.75rem 1.25rem;
  font-weight: 700; border-radius: 0 0 var(--og-radius) 0;
}
.skip-link:focus { left: 0; color: #fff; }

/* ==========================================================================
   4. Flag ribbon (thin tricolor accent used at top of site)
   ========================================================================== */
.og-ribbon {
  height: 6px;
  background: linear-gradient(
    to right,
    var(--og-red) 0 33.33%,
    var(--og-white) 33.33% 66.66%,
    var(--og-blue) 66.66% 100%
  );
}

/* ==========================================================================
   5. Header
   ========================================================================== */
.og-header {
  background: var(--og-white);
  border-bottom: 1px solid var(--og-line);
  position: sticky; top: 0; z-index: 50;
}
.og-header__inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding-block: 0.9rem;
}
.og-brand { display: flex; align-items: center; gap: 0.85rem; min-width: 0; }
.og-brand__mark {
  flex: none;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--og-blue);
  display: grid; place-items: center;
  box-shadow: inset 0 0 0 2px var(--og-gild);
}
.og-brand__mark svg { width: 24px; height: 24px; }
.og-brand__text { min-width: 0; }
.og-site-title {
  font-family: var(--og-font-display);
  font-weight: 700; font-size: 1.4rem; line-height: 1.05;
  margin: 0; letter-spacing: -0.01em;
}
.og-site-title a { color: var(--og-blue); text-decoration: none; }
.og-site-title a:hover { color: var(--og-red); }
.og-site-desc {
  margin: 0.1rem 0 0; font-size: 0.82rem; color: var(--og-slate);
  text-transform: uppercase; letter-spacing: 0.14em;
}
.custom-logo { max-height: 56px; width: auto; }

/* ==========================================================================
   6. Navigation
   ========================================================================== */
.og-nav-toggle {
  display: inline-flex; align-items: center; gap: 0.5rem;
  background: var(--og-blue); color: #fff; border: 0;
  padding: 0.55rem 0.9rem; border-radius: var(--og-radius);
  font: inherit; font-weight: 700; cursor: pointer;
}
.og-nav-toggle:hover { background: var(--og-red); }
.og-nav-toggle svg { width: 18px; height: 18px; }

.og-nav ul { list-style: none; margin: 0; padding: 0; }
.og-nav > ul { display: flex; align-items: center; gap: 0.25rem; }
.og-nav a {
  display: block; text-decoration: none; color: var(--og-navy-ink);
  font-weight: 600; padding: 0.55rem 0.85rem; border-radius: var(--og-radius);
  position: relative;
}
.og-nav a:hover, .og-nav a:focus { color: var(--og-blue); background: rgba(10, 49, 97, 0.06); }
.og-nav .current-menu-item > a { color: var(--og-red); }
.og-nav .current-menu-item > a::after {
  content: ""; position: absolute; left: 0.85rem; right: 0.85rem; bottom: 0.3rem;
  height: 2px; background: var(--og-red);
}

/* Sub-menus */
.og-nav .sub-menu {
  position: absolute; min-width: 13rem; background: #fff;
  box-shadow: var(--og-shadow); border: 1px solid var(--og-line);
  border-radius: var(--og-radius); padding: 0.4rem;
  opacity: 0; visibility: hidden; transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease; z-index: 40;
}
.og-nav li { position: relative; }
.og-nav li:hover > .sub-menu,
.og-nav li:focus-within > .sub-menu { opacity: 1; visibility: visible; transform: translateY(0); }

@media (max-width: 47.99rem) {
  .og-nav-toggle { display: inline-flex; }
  .og-nav {
    position: absolute; left: 0; right: 0; top: 100%;
    background: #fff; border-bottom: 1px solid var(--og-line);
    box-shadow: var(--og-shadow); padding: 0.5rem 1.25rem 1.25rem;
    display: none;
  }
  .og-nav.is-open { display: block; }
  .og-nav > ul { flex-direction: column; align-items: stretch; gap: 0; }
  .og-nav a { padding: 0.75rem 0.5rem; border-bottom: 1px solid var(--og-line); border-radius: 0; }
  .og-nav .current-menu-item > a::after { display: none; }
  .og-nav .sub-menu {
    position: static; opacity: 1; visibility: visible; transform: none;
    box-shadow: none; border: 0; padding-left: 1rem;
  }
}
@media (min-width: 48rem) {
  .og-nav-toggle { display: none; }
  .og-nav { display: block !important; }
}

/* ==========================================================================
   7. Hero (front page)
   ========================================================================== */
.og-hero {
  position: relative; overflow: hidden;
  background: var(--og-blue);
  color: var(--og-bunting);
  isolation: isolate;
}
.og-hero__stars {
  position: absolute; inset: 0; z-index: -1; opacity: 0.5;
  background-image: radial-gradient(var(--og-white) 1.1px, transparent 1.2px);
  background-size: 34px 34px; background-position: 0 0;
  -webkit-mask-image: linear-gradient(to bottom, #000 0, transparent 78%);
          mask-image: linear-gradient(to bottom, #000 0, transparent 78%);
}
.og-hero__inner {
  padding-block: clamp(3.5rem, 9vw, 7rem);
  max-width: 48rem;
}
.og-hero__eyebrow {
  display: inline-flex; align-items: center; gap: 0.5rem;
  color: var(--og-gild-soft); font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; font-size: 0.78rem;
  margin-bottom: 1rem;
}
.og-hero__eyebrow svg { width: 15px; height: 15px; }
.og-hero h1 {
  color: #fff; font-size: clamp(2.4rem, 6.5vw, 4.5rem);
  line-height: 1.02; margin: 0 0 1rem;
}
.og-hero p {
  font-size: clamp(1.1rem, 2.4vw, 1.4rem); color: #e9ecf2;
  max-width: 38rem; margin: 0 0 2rem;
}
.og-hero__actions { display: flex; flex-wrap: wrap; gap: 0.85rem; }
.og-hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 8px;
  background: repeating-linear-gradient(
    to right, var(--og-red) 0 12.5%, var(--og-bunting) 12.5% 25%);
}

/* ==========================================================================
   8. Buttons
   ========================================================================== */
.og-btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  font-weight: 700; text-decoration: none; cursor: pointer;
  padding: 0.8rem 1.5rem; border-radius: var(--og-radius);
  border: 2px solid transparent; font-size: 1rem;
  transition: transform 0.08s ease, background 0.15s ease, color 0.15s ease;
}
.og-btn:active { transform: translateY(1px); }
.og-btn--primary { background: var(--og-red); color: #fff; }
.og-btn--primary:hover, .og-btn--primary:focus { background: #97133a; color: #fff; }
.og-btn--ghost { background: transparent; color: #fff; border-color: rgba(255,255,255,0.55); }
.og-btn--ghost:hover, .og-btn--ghost:focus { background: #fff; color: var(--og-blue); border-color: #fff; }
.og-btn--solid { background: var(--og-blue); color: #fff; }
.og-btn--solid:hover, .og-btn--solid:focus { background: var(--og-red); color: #fff; }

/* ==========================================================================
   9. Section heading device (gild rule + star)
   ========================================================================== */
.og-section { padding-block: clamp(2.5rem, 6vw, 4.5rem); }
.og-section--tint { background: var(--og-white); border-block: 1px solid var(--og-line); }
.og-section__head { margin-bottom: 2rem; }
.og-section__head h2 { margin: 0; }
.og-section__rule {
  display: flex; align-items: center; gap: 0.6rem; margin-bottom: 0.9rem;
  color: var(--og-red);
}
.og-section__rule::after {
  content: ""; height: 2px; flex: 1; max-width: 4rem;
  background: linear-gradient(to right, var(--og-red), transparent);
}
.og-section__rule svg { width: 18px; height: 18px; flex: none; }

/* ==========================================================================
   10. Value cards (front page)
   ========================================================================== */
.og-cards {
  display: grid; gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr));
}
.og-card {
  background: var(--og-white); border: 1px solid var(--og-line);
  border-top: 3px solid var(--og-blue); border-radius: var(--og-radius);
  padding: 1.75rem; box-shadow: var(--og-shadow);
}
.og-card:nth-child(3n+2) { border-top-color: var(--og-red); }
.og-card:nth-child(3n) { border-top-color: var(--og-gild); }
.og-card__icon {
  width: 44px; height: 44px; border-radius: 50%;
  display: grid; place-items: center; margin-bottom: 1rem;
  background: rgba(10, 49, 97, 0.08); color: var(--og-blue);
}
.og-card__icon svg { width: 22px; height: 22px; }
.og-card h3 { margin: 0 0 0.5rem; font-size: 1.25rem; }
.og-card p { margin: 0; color: var(--og-slate); }

/* ==========================================================================
   11. Posts / articles
   ========================================================================== */
.og-post-grid {
  display: grid; gap: 2rem;
  grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr));
}
.og-card-post {
  background: var(--og-white); border: 1px solid var(--og-line);
  border-radius: var(--og-radius); overflow: hidden; box-shadow: var(--og-shadow);
  display: flex; flex-direction: column;
}
.og-card-post__thumb { display: block; aspect-ratio: 16 / 9; overflow: hidden; background: var(--og-blue); }
.og-card-post__thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.og-card-post:hover .og-card-post__thumb img { transform: scale(1.04); }
.og-card-post__body { padding: 1.35rem 1.4rem 1.5rem; display: flex; flex-direction: column; flex: 1; }
.og-card-post__title { font-size: 1.3rem; margin: 0.4rem 0 0.6rem; }
.og-card-post__title a { color: var(--og-blue); text-decoration: none; }
.og-card-post__title a:hover { color: var(--og-red); }
.og-card-post__excerpt { color: var(--og-slate); margin: 0 0 1rem; }
.og-card-post__more { margin-top: auto; font-weight: 700; text-decoration: none; }

.og-meta {
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.9rem; align-items: center;
  font-size: 0.82rem; color: var(--og-slate);
}
.og-meta a { color: var(--og-slate); text-decoration: none; }
.og-meta a:hover { color: var(--og-red); }
.og-cat-badge {
  background: var(--og-red); color: #fff; font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.05em; text-transform: uppercase;
  padding: 0.2rem 0.6rem; border-radius: 999px; text-decoration: none;
}
.og-cat-badge:hover { background: var(--og-blue); color: #fff; }

/* Single / page article */
.og-article { background: transparent; }
.og-article__header { margin-bottom: 1.75rem; }
.og-article__title { margin: 0.5rem 0 0.75rem; }
.og-featured { margin: 0 0 2rem; border-radius: var(--og-radius); overflow: hidden; box-shadow: var(--og-shadow); }
.og-content { max-width: var(--og-content); }
.og-content > * { max-width: 100%; }
.og-content h2 { margin-top: 2.25rem; }
.og-content h3 { margin-top: 1.75rem; }
.og-content ul, .og-content ol { padding-left: 1.4rem; margin: 0 0 1.25rem; }
.og-content li { margin-bottom: 0.4rem; }
.og-content img { border-radius: var(--og-radius); }
.og-content .alignwide { max-width: min(100%, 58rem); margin-inline: auto; }
.og-content .alignfull { max-width: 100vw; margin-inline: calc(50% - 50vw); }
.og-content .aligncenter { margin-inline: auto; }

.og-tags { margin-top: 2rem; display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.og-tag {
  font-size: 0.82rem; text-decoration: none; color: var(--og-blue);
  border: 1px solid var(--og-line); background: #fff;
  padding: 0.25rem 0.7rem; border-radius: 999px;
}
.og-tag:hover { border-color: var(--og-red); color: var(--og-red); }

/* ==========================================================================
   12. Sidebar / widgets
   ========================================================================== */
.og-sidebar .widget {
  background: var(--og-white); border: 1px solid var(--og-line);
  border-radius: var(--og-radius); padding: 1.4rem 1.5rem; margin-bottom: 1.5rem;
  box-shadow: var(--og-shadow);
}
.og-sidebar .widget-title {
  font-size: 1.1rem; margin: 0 0 1rem; padding-bottom: 0.6rem;
  border-bottom: 2px solid var(--og-red); display: inline-block;
}
.og-sidebar ul { list-style: none; margin: 0; padding: 0; }
.og-sidebar li { padding: 0.4rem 0; border-bottom: 1px solid var(--og-line); }
.og-sidebar li:last-child { border-bottom: 0; }
.og-sidebar a { text-decoration: none; color: var(--og-navy-ink); }
.og-sidebar a:hover { color: var(--og-red); }

/* ==========================================================================
   13. Pagination
   ========================================================================== */
.og-pagination { margin-top: 3rem; }
.og-pagination .nav-links { display: flex; flex-wrap: wrap; gap: 0.4rem; justify-content: center; }
.og-pagination .page-numbers {
  display: inline-grid; place-items: center; min-width: 2.6rem; height: 2.6rem;
  padding: 0 0.5rem; text-decoration: none; font-weight: 700;
  border: 1px solid var(--og-line); border-radius: var(--og-radius);
  background: #fff; color: var(--og-blue);
}
.og-pagination .page-numbers:hover { border-color: var(--og-red); color: var(--og-red); }
.og-pagination .page-numbers.current { background: var(--og-blue); color: #fff; border-color: var(--og-blue); }

/* ==========================================================================
   14. Comments
   ========================================================================== */
.og-comments { margin-top: 3rem; padding-top: 2rem; border-top: 2px solid var(--og-line); max-width: var(--og-content); }
.og-comments .comment-list { list-style: none; margin: 0; padding: 0; }
.og-comments .comment-list ol { list-style: none; padding-left: 1.5rem; }
.og-comments article { padding: 1.1rem 0; border-bottom: 1px solid var(--og-line); }
.og-comments .comment-author { font-weight: 700; color: var(--og-blue); }
.og-comments .comment-meta { font-size: 0.8rem; color: var(--og-slate); }
.og-comments .avatar { border-radius: 50%; float: left; margin-right: 0.85rem; }
.comment-respond input[type="text"],
.comment-respond input[type="email"],
.comment-respond input[type="url"],
.comment-respond textarea {
  width: 100%; padding: 0.7rem 0.85rem; border: 1px solid var(--og-line);
  border-radius: var(--og-radius); font: inherit; background: #fff;
}
.comment-respond label { display: block; font-weight: 600; margin: 0.75rem 0 0.3rem; }

/* ==========================================================================
   15. Footer
   ========================================================================== */
.og-footer { background: var(--og-blue-deep); color: #cdd6e4; margin-top: auto; }
.og-footer a { color: #fff; }
.og-footer a:hover { color: var(--og-gild-soft); }
.og-footer__top {
  display: grid; gap: 2rem; padding-block: clamp(2.5rem, 6vw, 4rem);
  grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr));
}
.og-footer .widget-title { color: #fff; font-size: 1.05rem; margin: 0 0 1rem; }
.og-footer ul { list-style: none; margin: 0; padding: 0; }
.og-footer li { padding: 0.3rem 0; }
.og-footer .widget a { text-decoration: none; }
.og-footer__brand p { color: #aab6cc; max-width: 26rem; }
.og-footer__bottom {
  border-top: 1px solid rgba(255,255,255,0.12);
  padding-block: 1.4rem; display: flex; flex-wrap: wrap; gap: 0.75rem;
  align-items: center; justify-content: space-between; font-size: 0.9rem;
}
.og-footer__flag { display: inline-flex; gap: 0.35rem; align-items: center; }
.og-footer__flag span { width: 14px; height: 10px; border-radius: 1px; }

/* ==========================================================================
   16. Utility / states
   ========================================================================== */
.og-page-header { margin-bottom: 2.5rem; }
.og-page-header .og-section__rule { justify-content: flex-start; }
.og-no-results { background: #fff; border: 1px solid var(--og-line); border-radius: var(--og-radius); padding: 2rem; }

.wp-caption { max-width: 100%; }
.wp-caption-text, .wp-block-image figcaption { font-size: 0.85rem; color: var(--og-slate); text-align: center; margin-top: 0.4rem; }
.alignleft { float: left; margin: 0.3rem 1.5rem 1rem 0; }
.alignright { float: right; margin: 0.3rem 0 1rem 1.5rem; }
.sticky .og-card-post { outline: 2px solid var(--og-gild); }
.bypostauthor { }

/* Focus visibility for accessibility */
a:focus-visible, button:focus-visible, input:focus-visible,
textarea:focus-visible, .og-btn:focus-visible, .page-numbers:focus-visible {
  outline: 3px solid var(--og-gild);
  outline-offset: 2px;
}

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