/**
 * WordPress additions to the MIRA design system.
 *
 * Built only from the tokens in main.css. Nothing here restyles the
 * prototype components; it covers states and templates the prototype
 * doesn't include (custom logo, search panel, content pages, pagination).
 *
 * @package gudzsvit
 */

/* =========================================================
   1. CORE HELPERS
   ========================================================= */
.skip-link:focus {
  top: var(--space-2); left: var(--space-2);
  z-index: 100;
  width: auto; height: auto;
  padding: var(--space-3) var(--space-4);
  clip: auto;
  background: var(--color-accent); color: var(--color-on-accent);
  font-size: var(--fs-sm);
  white-space: normal;
}

.admin-bar .site-header { top: 32px; }
@media (max-width: 782px) { .admin-bar .site-header { top: 46px; } }
@media (max-width: 600px) { .admin-bar .site-header { top: 0; } }

/* =========================================================
   2. HEADER ADDITIONS
   ========================================================= */
/* Custom logo image (the_custom_logo) */
.site-logo--image { margin-right: 0; letter-spacing: 0; }
.site-logo--image img { width: auto; max-height: 40px; }
.site-footer .site-logo--image img { max-height: 32px; }

/* Active parents (e.g. Shop while viewing a product) */
.primary-nav .current-menu-parent > a::after,
.primary-nav .current-menu-ancestor > a::after,
.primary-nav .current_page_parent > a::after { transform: scaleX(1); transform-origin: left; }

/* Search panel (toggled by the header search button) */
.search-panel {
  position: absolute; top: 100%; left: 0; right: 0;
  padding: var(--space-5) 0;
  background: var(--color-bg);
  border-bottom: 1px solid var(--color-border);
}
.search-panel[hidden] { display: none; }
.search-panel__inner { display: flex; align-items: center; gap: var(--space-3); }
.search-panel .search-form { flex: 1; max-width: none; }

.search-form { display: flex; gap: var(--space-3); max-width: 480px; }
.search-form .search-field {
  flex: 1; min-width: 0; min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-bg);
  transition: border-color .2s;
  -webkit-appearance: none; appearance: none;
}
.search-form .search-field::placeholder { color: #8a8a8a; }
.search-form .search-field:focus { border-color: var(--color-text); outline: none; }

/* =========================================================
   3. HERO / PRODUCT CARD ADDITIONS
   ========================================================= */
/* Banner image from ACF (prototype sizes the SVG the same way) */
.hero__media img { width: min(100%, 440px); height: auto; }
@media (max-width: 640px) { .hero__media img { width: 70%; } }

.product__quick-add-form { margin: 0; }
.product__quick-add[aria-busy="true"] { cursor: progress; }

/* Pin the quick-add bar to the bottom of the 4:5 image instead of the
   whole card, so it never covers the title/price (always visible ≤1024px). */
@supports (container-type: inline-size) {
  .products > .product { container-type: inline-size; }
  .products .product__quick-add { bottom: auto; top: calc(125cqi - 44px - var(--space-3)); }
}

.shop__empty { color: var(--color-muted); }

/* =========================================================
   4. NEWSLETTER STATES & EMBEDS
   ========================================================= */
.cta__status { margin-bottom: var(--space-4); font-size: var(--fs-sm); }
.cta__status--success { color: #2f6b3f; }
.cta__status--error { color: #a4262c; }

/* Contact Form 7 / MC4WP: wrap fields in <div class="newsletter-form"> */
.newsletter-embed { max-width: 480px; margin-inline: auto; }
.newsletter-form .wpcf7-form-control-wrap { flex: 1; min-width: 0; display: block; }
.newsletter-form .wpcf7-form-control-wrap input { width: 100%; }
.newsletter-embed input[type="submit"] { border: 1px solid var(--color-accent); background: var(--color-accent); color: var(--color-on-accent); min-height: 48px; padding: 0 var(--space-6); border-radius: var(--radius); font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: var(--tracking-wide); text-transform: uppercase; cursor: pointer; }
.newsletter-embed .wpcf7-response-output { margin: var(--space-4) 0 0; font-size: var(--fs-sm); }

/* =========================================================
   5. CONTENT PAGES (page.php, single.php)
   ========================================================= */
.page-main { padding: var(--space-8) 0 var(--space-9); }
.page-header { margin-bottom: var(--space-7); }
.page-title {
  font-size: clamp(1.75rem, 3.5vw, 2.5rem);
  font-weight: var(--fw-regular);
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.archive-description { margin-top: var(--space-3); color: var(--color-muted); max-width: 60ch; }
.entry-meta { margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--color-muted); }
.edit-link { margin-top: var(--space-6); font-size: var(--fs-xs); color: var(--color-muted); }

.entry:not(.entry--wide) { max-width: 760px; margin-inline: auto; }
.entry-thumbnail { margin: 0 0 var(--space-7); background: var(--color-surface); border-radius: var(--radius); overflow: hidden; }
.entry-thumbnail img { width: 100%; height: auto; }
.entry-footer { margin-top: var(--space-7); padding-top: var(--space-5); border-top: 1px solid var(--color-border); }

/* Prose (restores spacing removed by the base reset) */
.entry:not(.entry--wide) .entry-content { line-height: 1.75; }
.entry:not(.entry--wide) .entry-content > * + * { margin-top: var(--space-5); }
.entry:not(.entry--wide) .entry-content h2 { margin-top: var(--space-7); font-size: var(--fs-xl); font-weight: var(--fw-medium); letter-spacing: -0.01em; line-height: 1.3; }
.entry:not(.entry--wide) .entry-content h3 { margin-top: var(--space-6); font-size: var(--fs-lg); font-weight: var(--fw-medium); line-height: 1.35; }
.entry:not(.entry--wide) .entry-content :where(ul, ol) { padding-left: 1.25em; }
.entry:not(.entry--wide) .entry-content ul { list-style: disc; }
.entry:not(.entry--wide) .entry-content li + li { margin-top: var(--space-2); }
.entry:not(.entry--wide) .entry-content a:not([class]) { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.entry:not(.entry--wide) .entry-content a:not([class]):hover { color: var(--color-muted); }
.entry-content blockquote { margin-inline: 0; padding-left: var(--space-5); border-left: 2px solid var(--color-accent); font-size: var(--fs-lg); font-weight: var(--fw-light); }
.entry-content figure { margin-inline: 0; }
.entry-content img { height: auto; }
.entry-content figcaption, .wp-caption-text { margin-top: var(--space-2); font-size: var(--fs-xs); color: var(--color-muted); }
.entry-content hr { border: 0; border-top: 1px solid var(--color-border); margin-block: var(--space-7); }
.entry-content table:not([class]) { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.entry-content table:not([class]) :where(th, td) { padding: var(--space-3); border-bottom: 1px solid var(--color-border); text-align: left; }
.page-links { font-size: var(--fs-sm); }

.alignleft { float: left; margin: 0 var(--space-5) var(--space-4) 0; }
.alignright { float: right; margin: 0 0 var(--space-4) var(--space-5); }
.aligncenter { margin-inline: auto; }

/* Block buttons match .btn */
.wp-block-button__link {
  min-height: 48px;
  padding: var(--space-3) var(--space-6);
  border: 1px solid var(--color-accent); border-radius: var(--radius);
  background: var(--color-accent); color: var(--color-on-accent);
  font-size: var(--fs-sm); font-weight: var(--fw-medium);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
.wp-block-button__link:hover { background: #333; border-color: #333; }
.is-style-outline .wp-block-button__link { background: transparent; color: var(--color-text); }
.is-style-outline .wp-block-button__link:hover { background: var(--color-accent); color: var(--color-on-accent); }

/* Shared form controls (content pages, comments, classic WooCommerce) */
:where(.entry:not(.entry--wide) .entry-content, .comments-area, .woocommerce) :where(input[type="text"], input[type="email"], input[type="tel"], input[type="url"], input[type="password"], input[type="number"], input[type="search"], textarea, select) {
  width: 100%;
  min-height: 48px;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  background: var(--color-bg);
  transition: border-color .2s;
}
:where(.entry:not(.entry--wide) .entry-content, .comments-area, .woocommerce) :where(input, textarea, select):focus { border-color: var(--color-text); }
:where(.comments-area, .woocommerce) textarea { min-height: 140px; resize: vertical; }

/* =========================================================
   6. POST LISTINGS
   ========================================================= */
.post-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  column-gap: var(--space-5);
  row-gap: var(--space-7);
}
.post-card__link { display: block; }
.post-card__media { aspect-ratio: 4 / 3; margin-bottom: var(--space-4); background: var(--color-surface); border-radius: var(--radius); overflow: hidden; }
.post-card__media img { width: 100%; height: 100%; object-fit: cover; transition: transform 700ms var(--ease); }
.post-card:hover .post-card__media img { transform: scale(1.04); }
.post-card__title { font-size: var(--fs-lg); font-weight: var(--fw-medium); line-height: 1.35; }
.post-card .entry-meta { margin-top: var(--space-1); }
.post-card__excerpt { margin-top: var(--space-3); font-size: var(--fs-sm); color: var(--color-muted); }

.post-navigation { max-width: 760px; margin: var(--space-8) auto 0; }
.post-navigation .nav-links { display: flex; justify-content: space-between; gap: var(--space-5); padding-top: var(--space-5); border-top: 1px solid var(--color-border); }
.post-navigation .nav-next { margin-left: auto; text-align: right; }
.nav-subtitle { display: block; font-size: var(--fs-xs); letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--color-muted); }

/* Pagination (WordPress + WooCommerce) */
.pagination, .woocommerce-pagination { margin-top: var(--space-8); }
.pagination .nav-links, .woocommerce-pagination ul { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); }
a.page-numbers, span.page-numbers {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 44px; height: 44px; padding: 0 var(--space-3);
  border: 1px solid var(--color-border); border-radius: var(--radius);
  font-size: var(--fs-sm);
  transition: border-color .2s, background .2s;
}
a.page-numbers:hover { border-color: var(--color-text); }
span.page-numbers.current { background: var(--color-accent); border-color: var(--color-accent); color: var(--color-on-accent); }
span.page-numbers.dots { border-color: transparent; }

/* =========================================================
   7. COMMENTS
   ========================================================= */
.comments-area { max-width: 760px; margin: var(--space-8) auto 0; padding-top: var(--space-7); border-top: 1px solid var(--color-border); }
.comments-title, .comment-reply-title { margin-bottom: var(--space-5); font-size: var(--fs-lg); font-weight: var(--fw-medium); }
.comment-list .comment { padding: var(--space-5) 0; border-bottom: 1px solid var(--color-border); }
.comment-list .children { padding-left: var(--space-6); }
.comment-meta, .comment-metadata { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-3); font-size: var(--fs-sm); color: var(--color-muted); }
.comment .avatar { border-radius: 50%; }
.comment-content { margin-top: var(--space-3); }
.comment-content p + p { margin-top: var(--space-3); }
.comment-form > p { margin-bottom: var(--space-4); }
.comment-form label { display: block; margin-bottom: var(--space-2); font-size: var(--fs-xs); font-weight: var(--fw-medium); letter-spacing: var(--tracking-wide); text-transform: uppercase; }
.comment-form .comment-form-cookies-consent label { display: inline; text-transform: none; letter-spacing: 0; font-size: var(--fs-sm); font-weight: var(--fw-regular); }
.comment-form input[type="submit"] {
  min-height: 48px; padding: 0 var(--space-6);
  border: 1px solid var(--color-accent); border-radius: var(--radius);
  background: var(--color-accent); color: var(--color-on-accent);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); letter-spacing: var(--tracking-wide); text-transform: uppercase;
  cursor: pointer;
}

/* =========================================================
   8. 404 / EMPTY STATES
   ========================================================= */
.error-404, .no-results { max-width: 640px; margin-inline: auto; text-align: center; }
.error-404 .page-title { margin-bottom: var(--space-4); }
.error-404 .search-form, .no-results .search-form { margin: var(--space-6) auto 0; }
.no-results p { color: var(--color-muted); }
.error-404__back { margin-top: var(--space-6); }

/* =========================================================
   9. RESPONSIVE
   ========================================================= */
@media (max-width: 1024px) {
  .post-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .page-main { padding: var(--space-6) 0 var(--space-8); }
  .post-grid { grid-template-columns: 1fr; }
  .search-form { flex-direction: column; }
  .search-panel .search-form { flex-direction: row; }
  .search-panel .search-form .btn { padding: 0 var(--space-4); }
}
