/*
Theme Name: Pacepals
Theme URI: https://example.com/pacepals
Author: johlits
Author URI: https://example.com
Description: Light-themed WordPress theme with single-column posts and minimal link interactions.
Version: 1.0.9
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: pacepals
Tags: light, responsive, one-column, blog, sidebar
*/

/* Root variables (light theme) */
:root{
  --bg: #ffffff;
  --bg-elev: #f6f7f9;
  --text: #111318;
  --muted: #5a6270;
  --primary: #1f2937; /* headings */
  --primary-600: #111827;
  --border: #e3e7ee;
  --card: #ffffff;
  --accent: #1663c7; /* brand blue */
}

html { box-sizing: border-box; }
*, *:before, *:after { box-sizing: inherit; }

body{
  margin: 0; font-family: "Familjen Grotesk", "Segoe UI", Roboto, Helvetica, Arial, sans-serif; color: var(--text); background: var(--bg);
  font-size: 17px; line-height: 1.4; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}

/* Guard against horizontal overflow on mobile */
html, body { max-width: 100%; overflow-x: hidden; }

img{ max-width: 100%; height: auto; display: block; }

/* Layout */
.site-header{ background: var(--bg); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.site-header .header-inner{ width: min(1200px, 92%); margin: 0 auto; }
.container{ width: min(1200px, 92%); margin: 0 auto; }
.site-content, .site-main{ width: min(1200px, 92%); margin: 0 auto; }
@media (min-width: 901px){
  /* Constrain main content to the same container width on desktop */
  .main,
  .site-content, .site-main,
  main, #primary, #content{ width: min(1200px, 92%); margin: 0 auto; }
  /* Let .content and .entry fill their grid track naturally (like front page) */
}
.header-inner{ display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 8px 0; flex-wrap: nowrap; min-width: 0; }
.site-title a{ color: var(--primary); text-decoration: none; font-weight: 700; font-size: 2.5rem; line-height: 1.2; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Site icon branding */
.branding{ display: flex; align-items: center; gap: 14px; flex: 1 1 auto; min-width: 0; }
.branding .site-icon-link{ display: inline-flex; align-items: center; line-height: 0; }
.branding .site-icon{ width: 48px; height: 48px; border-radius: 8px; display: block; }
.site-description{ color: var(--muted); font-size: .9rem; margin-top: 2px; }

/* Navigation */
.menu-toggle{ display: none; background: transparent; border: 1px solid var(--border); color: var(--text); padding: 8px 10px; border-radius: 6px; flex: 0 0 auto; }
.primary-nav{ position: relative; }
.primary-nav .menu{ list-style: none; padding: 0; margin: 0; display: flex; gap: 10px; }
.primary-nav .menu, .primary-nav .menu ul, .primary-nav .menu li{ list-style: none; margin: 0; padding: 0; }
.primary-nav .menu > li{ position: relative; }
.primary-nav a{ color: var(--text); text-decoration: none; padding: 10px 12px; display: block; border-radius: 6px; }
.primary-nav a:hover, .primary-nav .current-menu-item > a{ background: #eef2f8; }
/* Expanded state highlight and caret flip */
.primary-nav .menu > li.open > a,
.primary-nav .menu > li.open-desktop > a{ background: #eef2f8; }
.primary-nav .menu li.menu-item-has-children > a::after{ content: "▾"; margin-left: .4rem; font-size: .8em; color: var(--muted); }
.primary-nav .menu > li.open > a::after,
.primary-nav .menu > li.open-desktop > a::after{ content: "▴"; }
/* Focus-visible for accessibility */
.primary-nav a:focus-visible, .menu-toggle:focus-visible{ outline: 2px solid var(--accent); outline-offset: 2px; }

/* Dropdowns */
.primary-nav ul, .primary-nav li{ list-style: none; margin: 0; padding: 0; }
.primary-nav .sub-menu{ list-style: none; position: absolute; left: 0; top: 100%; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; min-width: 200px; padding: 6px; margin: 0; display: none; box-shadow: 0 10px 30px rgba(17,24,39,.15); }
.primary-nav .sub-menu ul, .primary-nav .sub-menu li{ list-style: none; margin: 0; padding: 0; }
.primary-nav .sub-menu li{ position: relative; list-style: none; }
.primary-nav li:hover > .sub-menu, .primary-nav li:focus-within > .sub-menu{ display: block; }
.primary-nav .sub-menu a{ padding: 8px 10px; }
.primary-nav .menu li.menu-item-has-children > a::after{ content: "▾"; margin-left: .4rem; font-size: .8em; color: var(--muted); }

/* Nested submenus default open to the right */
.primary-nav .sub-menu .sub-menu{ top: 0; left: 100%; }
/* Flip right-edge dropdowns to open inward (to the left) */
.primary-nav .menu > li:last-child > .sub-menu,
.primary-nav .menu > li:nth-last-child(1) > .sub-menu{ right: 0; left: auto; }
/* And ensure their children open to the left as well */
.primary-nav .menu > li:last-child > .sub-menu .sub-menu,
.primary-nav .menu > li:nth-last-child(1) > .sub-menu .sub-menu{ left: auto; right: 100%; top: 0; }

/* Mobile nav */
@media (max-width: 900px){
  /* Use consistent 8px gutters via header/content wrappers (not body) */
  body{ padding-left: 0; padding-right: 0; }
  .menu-toggle{ display: inline-flex; align-items: center; gap: 8px; }
  /* Header inherits body gutters */
  .header-inner{ padding-left: 8px; padding-right: 8px; }
  .site-header .header-inner{ width: 100%; margin: 0; }
  /* Ensure pages mirror front page gutters explicitly */
  .site-header{ padding-left: 0; padding-right: 0; box-sizing: border-box; }
  /* Apply 8px gutters only to primary layout wrappers to match front page */
  .container,
  .main{ padding-left: 8px; padding-right: 8px; box-sizing: border-box; }
  /* Ensure other wrappers do not add extra padding */
  .site-content, .site-main,
  .content, .entry, .post, .page,
  main, #primary, #content{ padding-left: 0; padding-right: 0; box-sizing: border-box; }
  /* Make wrappers full width so only body provides gutters */
  .container,
  .main,
  .site-content, .site-main,
  .content, .entry, .post, .page,
  main, #primary, #content{ width: 100%; margin-left: 0; margin-right: 0; }
  /* Add a couple of pixels inside content on small screens (front page and pages) */
  .content, .entry{ padding-left: 6px; padding-right: 6px; }
  /* Ensure widgets (sidebar) also get side gutters on small screens */
  .sidebar{ padding-left: 6px; padding-right: 6px; box-sizing: border-box; }
  /* Keep header single-row; menu opens as a fixed panel under the header on the right */
  .primary-nav .menu{ display: none; position: fixed; left: 8px; right: 8px; top: calc(var(--header-height, 64px) + 8px); flex-direction: column; background: var(--bg-elev); border: 1px solid var(--border); border-radius: 8px; padding: 8px; width: auto; max-width: calc(100vw - 16px); box-sizing: border-box; z-index: 1000; max-height: calc(100vh - (var(--header-height, 64px) + 16px)); overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .primary-nav.open .menu{ display: flex; }
  .primary-nav .sub-menu{ position: static; border: none; box-shadow: none; padding-left: 10px; display: none; }
  .primary-nav .menu li.open > .sub-menu{ display: block; }
  /* Hide large text title on small screens; keep logo only */
  .branding{ gap: 8px; }
  .site-title, .site-title a{ display: none !important; }
  .site-description{ display: none; }
  /* Clamp widths to viewport and prevent horizontal overflow */
  .container, .main, .content, .grid, .entry{ max-width: 100%; width: 100%; overflow-x: hidden; }
  .grid{ width: 100%; }
  /* Remove any default extra paddings elsewhere; wrappers provide gutters */
  /* Switch to single column layout and relax sticky sidebar */
  .main{ grid-template-columns: 1fr; }
  .sidebar{ position: static; top: auto; width: 100%; max-width: 100%; }
  html, body{ max-width: 100%; overflow-x: hidden; }
  /* Ensure flex/grid children can shrink without forcing overflow */
  .header-inner > *, .branding > *, .main > *, .grid > *, .card > *, .entry > *{ min-width: 0; }
  /* Wrap anywhere inside content and cards */
  .content, .entry, .card-body{ overflow-wrap: anywhere; word-break: break-word; }
}

/* Tighten on ultra-small screens to ensure single row */
@media (max-width: 400px){
  .branding .site-icon{ width: 40px; height: 40px; }
  .site-title a{ font-size: 1.8rem; }
}

/* Ultra-small screens: tighten spacing and font size */
@media (max-width: 360px){
  body{ font-size: 15px; }
  .header-inner{ gap: 8px; }
  .primary-nav a{ padding: 8px 10px; }
  .card-body{ padding: 10px; }
}

/* Main layout */
.main{ display: grid; grid-template-columns: minmax(0, 1fr) 240px; grid-template-areas: "content sidebar"; gap: 24px; padding: 24px 0; }
.main > .content{ grid-area: content; }
.main > .sidebar{ grid-area: sidebar; }
/* Auto-placed children (e.g. injected ads) stay in column 1, don't displace content/sidebar */
.main > *:not(.content):not(.sidebar){ grid-column: 1; }
@media (max-width: 900px){ .main{ grid-template-columns: 1fr; grid-template-areas: "content" "sidebar"; } .main > *:not(.content):not(.sidebar){ grid-column: 1; } }

.sidebar{ position: sticky; top: 76px; height: fit-content; }
.widget{ background: var(--bg-elev); border: 1px solid var(--border); border-radius: 10px; padding: 14px; margin-bottom: 16px; }
.widget-title{ margin-top: 0; font-size: 1.05rem; border-bottom: 1px solid var(--border); padding-bottom: 8px; }
/* Remove any top spacing from widget headings */
.widget h2, .widget .widget-title{ margin-top: 0; margin-bottom: 6px; }

/* Cards grid (front page) - single column */
.grid{ display: grid; grid-template-columns: 1fr; gap: 16px; }

.card{ background: var(--card); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; min-width: 0; }
.card-thumb{ aspect-ratio: 16/9; background: #e9eef6; }
.card-body{ padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.card-title{ margin: 0; font-size: 1.05rem; }
.home .card-title, .front-page .card-title{ font-size: 1.15rem; }
.card-title a{ color: var(--text); text-decoration: none; }
.card-meta{ color: var(--muted); font-size: .85rem; }
.card-excerpt{ color: var(--muted); font-size: .95rem; }
.card a.more{ align-self: flex-start; margin-top: 6px; font-weight: 600; color: var(--accent); text-decoration: none; border: none; border-radius: 8px; padding: 0; background: transparent; }

/* Pagination */
.pagination{ display: flex; justify-content: center; margin-top: 16px; }
nav.navigation.pagination{ display: flex; justify-content: center; margin-top: 16px; }
nav.navigation.pagination .nav-links{ display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.pagination .nav-links{ display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.page-numbers{ display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: #fff; color: var(--text) !important; text-decoration: none; font-weight: 600; transition: background .2s ease, color .2s ease, border-color .2s ease; }
.page-numbers:hover, .page-numbers:focus{ background: #f1f5fb; color: var(--accent) !important; outline: none; border-color: var(--border); }
.page-numbers.current{ background: var(--accent); color: #fff !important; border-color: transparent; cursor: default; }
.page-numbers.dots{ background: transparent; border: none; color: var(--muted) !important; min-width: auto; padding: 0 4px; }
.page-numbers.prev, .page-numbers.next{ padding: 0 12px; }

@media (max-width: 640px){
  .page-numbers{ min-width: 32px; height: 32px; border-radius: 6px; padding: 0 8px; }
}

/* Footer */
.site-footer{ border-top: 1px solid var(--border); background: var(--bg-elev); padding: 20px 0; color: var(--muted); text-align: center; }

/* Global link styles */
body a:link, body a:visited,
.content a:link, .content a:visited,
.entry a:link, .entry a:visited,
.widget a:link, .widget a:visited,
nav a:link, nav a:visited,
.site-footer a:link, .site-footer a:visited{ color: var(--text) !important; text-decoration: none; }

body a:hover, body a:focus,
.content a:hover, .content a:focus,
.entry a:hover, .entry a:focus,
.widget a:hover, .widget a:focus,
nav a:hover, nav a:focus,
.site-footer a:hover, .site-footer a:focus{ color: var(--accent) !important; }

/* Responsive typography scale */
h1{ font-size: clamp(1.8rem, 1.2rem + 2vw, 2.6rem); line-height: 1.2; margin: 0 0 12px; color: var(--primary); }
h2{ font-size: clamp(1.5rem, 1.1rem + 1.4vw, 2.1rem); line-height: 1.25; margin: 0 0 10px; color: var(--primary); }
h3{ font-size: clamp(1.3rem, 1.05rem + 1vw, 1.7rem); line-height: 1.3; margin: 0 0 8px; color: var(--primary); }
h4{ font-size: 1.2rem; line-height: 1.35; margin: 0 0 8px; color: var(--primary); }
h5{ font-size: 1.05rem; line-height: 1.4; margin: 0 0 6px; color: var(--primary); }
h6{ font-size: 1rem; line-height: 1.4; margin: 0 0 6px; color: var(--primary); }

/* Buttons */
.button, .wp-block-button__link,
button, input[type="button"], input[type="submit"], input[type="reset"]{
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--accent); color: #fff; border: none;
  padding: 10px 14px; border-radius: 10px; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.button:hover, .wp-block-button__link:hover,
button:hover, input[type="button"]:hover, input[type="submit"]:hover, input[type="reset"]:hover{
  background: #1253a9; text-decoration: none;
}
.button:active, .wp-block-button__link:active,
button:active, input[type="button"]:active, input[type="submit"]:active, input[type="reset"]:active{
  transform: translateY(1px);
}
.wp-block-button.is-style-outline .wp-block-button__link{ background: transparent; color: var(--accent); border: 1px solid var(--accent); }

/* Forms */
input[type="text"], input[type="email"], input[type="url"], input[type="search"], input[type="password"],
input[type="number"], input[type="tel"], select, textarea{
  width: 100%; max-width: 100%;
  background: #fff; color: var(--text);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
input:focus, select:focus, textarea:focus{
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(22, 99, 199, .15);
}

/* Minor guards */
.content{ min-width: 0; }
.branding, .header-inner{ min-width: 0; }

/* Entry/content typography */
.entry{ color: var(--text); line-height: 1.4; }
.entry h1, .entry h2, .entry h3, .entry h4, .entry h5, .entry h6{ color: var(--primary); line-height: 1.25; margin: 0 0 12px; }
.entry p{ margin: 0 0 12px; }
.page-hero{ position: relative; border-radius: 10px; overflow: hidden; margin: 0 0 16px; height: clamp(180px, 30vw, 320px); }
.page-hero::after{ content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0.45), rgba(0,0,0,0.15) 45%, rgba(0,0,0,0.55)); z-index: 1; }
.page-hero-image{ width: 100%; height: 100%; display: block; object-fit: cover; }
.page-hero-title{
  position: absolute; left: 18px; bottom: 16px; right: 18px;
  margin: 0; color: #ffffff; line-height: 1.1; z-index: 2;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.8),
    0 0 6px rgba(0,0,0,0.6),
    1px 0 0 rgba(0,0,0,0.9),
    -1px 0 0 rgba(0,0,0,0.9),
    0 1px 0 rgba(0,0,0,0.9),
    0 -1px 0 rgba(0,0,0,0.9);
}
.page-header h1{ margin-top: 0; }
.entry ul, .entry ol{ margin: 0 0 12px; padding-left: 1.25rem; }
.entry li{ margin: 4px 0; }
.entry blockquote{ margin: 12px 0; padding: 10px 14px; border-left: 3px solid var(--border); background: var(--bg-elev); border-radius: 6px; }
.entry hr{ border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
.entry table{ width: 100%; border-collapse: collapse; margin: 12px 0; }
.entry th, .entry td{ border: 1px solid var(--border); padding: 8px; text-align: left; }

/* Ensure content never overflows viewport */
.entry, .post, .page{ max-width: 100%; overflow-x: hidden; }
.entry img, .entry iframe, .entry embed, .entry object, .entry video{
  display: block;
  max-width: 100% !important;
  height: auto;
  border: 0;
}
/* Make tables scroll within the viewport instead of overflowing */
.entry table{ display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.entry pre{ max-width: 100%; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.entry code, .entry kbd, .entry samp{ word-break: break-word; overflow-wrap: anywhere; }
.card-title, .card-excerpt{ overflow-wrap: anywhere; word-break: break-word; }

/* WordPress block alignment guards */
.entry .alignwide, .entry .alignfull{
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}
.entry figure{ max-width: 100%; }
.entry a{ overflow-wrap: anywhere; word-break: break-word; }

/* Gutenberg columns and embeds: prevent overflow on small screens */
.entry .wp-block-columns{ margin-left: 0 !important; margin-right: 0 !important; }
.entry .wp-block-column{ min-width: 0; }
@media (max-width: 900px){
  .entry .wp-block-columns{ display: block; }
}
.entry .wp-block-embed, .entry .wp-block-video, .entry .wp-block-image{
  max-width: 100% !important;
  overflow-x: auto;
}
.entry iframe, .entry .wp-block-embed iframe{
  width: 100% !important;
  max-width: 100% !important;
}
