/*
Theme Name: 新電子
Theme URI: https://www.mem.com.tw
Author: Inbound Marketing
Description: 新電子科技雜誌傳統 PHP 佈景（取代 Elementor / Unlimited Elements）
Version: 0.2.0
Text Domain: mem
*/

:root {
  --brand: #1d2088;
  --brand-dark: #15176a;
  --accent: #e31c23;
  --paper: #ffffff;
  --surface: #f5f6fb;
  --ink: #1a1a2e;
  --ink-soft: #5a5d73;
  --rule: #e2e4ef;
  --max: 1070px;
  --header-h: 80px;
  --wp-admin-bar-h: 0px;
}

body.admin-bar {
  --wp-admin-bar-h: 32px;
}

@media screen and (max-width: 782px) {
  body.admin-bar {
    --wp-admin-bar-h: 46px;
  }
}

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

html {
  scroll-padding-top: calc(var(--header-h) + var(--wp-admin-bar-h));
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "微軟正黑體", sans-serif;
  line-height: 1.7;
  letter-spacing: 0.03em;
  color: var(--ink);
  background: var(--paper);
}

a {
  color: var(--brand);
  text-decoration: none;
}

a:hover {
  color: var(--brand-dark);
}

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

.screen-reader-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.wrap {
  width: min(100% - 2rem, var(--max));
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: var(--wp-admin-bar-h);
  z-index: 100;
  background: #fff;
  border-bottom: 1px solid var(--rule);
  box-shadow: 0 1px 0 rgba(29, 32, 136, 0.04);
}

.site-header__inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: var(--header-h);
}

.site-brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.site-brand__logo {
  display: block;
  width: auto;
  height: 48px;
}

.site-nav {
  flex: 1 1 auto;
}

.site-nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.site-nav a {
  color: var(--ink);
  font-weight: 500;
  font-size: 0.95rem;
}

.site-nav .current-menu-item > a,
.site-nav a:hover {
  color: var(--brand);
}

.site-header__tools {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-left: auto;
}

.site-search {
  display: flex;
  gap: 0.25rem;
}

.site-search input {
  width: 9rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
}

.site-search button,
.btn {
  appearance: none;
  border: 0;
  border-radius: 4px;
  background: var(--brand);
  color: #fff;
  padding: 0.4rem 0.85rem;
  cursor: pointer;
  font: inherit;
}

.site-search button:hover,
.btn:hover {
  background: var(--brand-dark);
}

.site-header__toggler {
  display: none;
  width: 2.5rem;
  height: 2.5rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  background: #fff;
  padding: 0.55rem;
  flex-direction: column;
  justify-content: space-between;
}

.site-header__toggler span {
  display: block;
  height: 2px;
  background: var(--ink);
}

.site-main {
  padding: 1.5rem 0 3rem;
}

.section {
  margin: 1.75rem 0;
}

.section__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.85rem;
  border-bottom: 2px solid var(--brand);
}

.section__title {
  margin: 0;
  padding: 0.45rem 0.8rem;
  background: var(--brand);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.section__more {
  color: var(--brand);
  font-size: 0.9rem;
}

.post-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
}

.post-grid--3 {
  grid-template-columns: repeat(3, 1fr);
}

.post-grid--2 {
  grid-template-columns: repeat(2, 1fr);
}

.post-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.post-card__thumb {
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: var(--surface);
  border-radius: 4px;
}

.post-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.post-card__title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.45;
  font-weight: 700;
}

.post-card__title a {
  color: var(--ink);
}

.post-card__meta {
  color: var(--ink-soft);
  font-size: 0.85rem;
}

.post-list {
  display: grid;
  gap: 1rem;
}

.post-list__item {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--rule);
}

.entry {
  max-width: 760px;
}

.entry__title {
  margin: 0 0 0.75rem;
  font-size: clamp(1.5rem, 2.4vw, 2rem);
  line-height: 1.35;
}

.entry__meta {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-bottom: 1.25rem;
}

.entry__content {
  font-size: 1.05rem;
}

.entry__content p {
  margin: 0 0 1.1rem;
}

.entry__thumb {
  margin: 0 0 1.25rem;
}

.breadcrumbs {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-bottom: 1rem;
}

.breadcrumbs a {
  color: var(--ink-soft);
}

.pagination {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.pagination .page-numbers {
  display: inline-block;
  padding: 0.35rem 0.7rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
  color: var(--ink);
}

.pagination .current {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}

.site-footer {
  background: #11142a;
  color: #d7daef;
  padding: 2.5rem 0 1.5rem;
  margin-top: 2rem;
}

.site-footer a {
  color: #d7daef;
}

.site-footer__grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 1.5rem;
}

.site-footer__copy {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 0.85rem;
  color: #9aa0c2;
}

.ad-slot {
  margin: 1rem 0;
  text-align: center;
}

.ad-slot__label {
  display: block;
  font-size: 0.75rem;
  color: var(--ink-soft);
  margin-bottom: 0.35rem;
}

.mem-form {
  display: grid;
  gap: 0.85rem;
  max-width: 420px;
}

.mem-form label {
  display: grid;
  gap: 0.3rem;
  font-size: 0.95rem;
}

.mem-form input,
.mem-form select,
.mem-form textarea {
  font: inherit;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--rule);
  border-radius: 4px;
}

.mem-form__msg {
  padding: 0.75rem 1rem;
  border-radius: 4px;
  background: #eef7ee;
  color: #1f5a2b;
}

.mem-form__msg--error {
  background: #fdeeee;
  color: #8a1f1f;
}

.home-layout {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 1.5rem;
}

.home-side .section {
  margin-top: 0;
}

@media (max-width: 960px) {
  .post-grid,
  .post-grid--3 {
    grid-template-columns: repeat(2, 1fr);
  }

  .home-layout,
  .site-footer__grid,
  .post-list__item {
    grid-template-columns: 1fr;
  }

  .site-header__toggler {
    display: flex;
  }

  .site-nav {
    display: none;
    position: absolute;
    left: 0;
    right: 0;
    top: 100%;
    background: #fff;
    border-bottom: 1px solid var(--rule);
    padding: 1rem;
  }

  .site-nav.is-open {
    display: block;
  }

  .site-nav ul {
    flex-direction: column;
  }

  .site-search input {
    width: 100%;
  }
}

@media (max-width: 600px) {
  .post-grid,
  .post-grid--2,
  .post-grid--3 {
    grid-template-columns: 1fr;
  }
}
