/* ==========================================================================
   許育碩律師事務所 — Typography-First Design
   設計哲學：Butterick's Typography for Lawyers + Brutalist Web Design
   ========================================================================== */

/* --- CSS Custom Properties --- */
:root {
  /* Typography */
  --font-serif: 'Noto Serif TC', 'Songti TC', 'Songti SC', 'STSong', 'PMingLiU', Georgia, serif;
  --font-sans: 'PingFang TC', 'Microsoft JhengHei', 'Noto Sans TC', 'Helvetica Neue', Arial, sans-serif;
  --base-size: 18px;
  --line-height: 1.8;
  --heading-line-height: 1.35;
  --content-width: 38rem;
  --page-padding: 1.5rem;

  /* Colors — Option B: Warm White */
  --bg: #faf8f5;
  --text: #1a1a1a;
  --text-secondary: #555;
  --link: #2c5f8a;
  --link-visited: #5a3d6e;
  --border: #d4cfc8;
  --line-green: #06C755;
  --line-green-hover: #05b34c;
  --bg-subtle: #f0ece6;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a1a1a;
    --text: #e8e4df;
    --text-secondary: #a8a29e;
    --link: #7db4d8;
    --link-visited: #b89fd6;
    --border: #3a3632;
    --bg-subtle: #252220;
  }
}

/* --- Reset --- */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* --- Base --- */
html {
  font-size: var(--base-size);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  hanging-punctuation: allow-end;
}

body {
  font-family: var(--font-serif);
  line-height: var(--line-height);
  color: var(--text);
  background-color: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Typography --- */
h1, h2, h3, h4 {
  font-family: var(--font-serif);
  line-height: var(--heading-line-height);
  letter-spacing: 0.02em;
}

h1 {
  font-size: 2.4rem;
  font-weight: 400;
  margin-bottom: 1rem;
}

h2 {
  font-size: 1.6rem;
  font-weight: 600;
  margin-top: 2.5rem;
  margin-bottom: 0.75rem;
}

h3 {
  font-size: 1.25rem;
  font-weight: 500;
  margin-top: 2rem;
  margin-bottom: 0.5rem;
}

p {
  margin-bottom: 1.25rem;
}

/* Brutalist: links MUST be underlined */
a {
  color: var(--link);
  text-decoration: underline;
  text-underline-offset: 0.15em;
  text-decoration-thickness: 1px;
}

a:visited {
  color: var(--link-visited);
}

a:hover,
a:focus {
  text-decoration-thickness: 2px;
}

blockquote {
  border-left: 3px solid var(--border);
  padding-left: 1.25rem;
  margin: 1.5rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

ul, ol {
  margin-bottom: 1.25rem;
  padding-left: 1.5rem;
}

li {
  margin-bottom: 0.35rem;
}

li > ul, li > ol {
  margin-bottom: 0;
  margin-top: 0.35rem;
}

strong {
  font-weight: 600;
}

em {
  font-style: italic;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2.5rem 0;
}

/* --- Layout --- */
.page-wrapper {
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 0 var(--page-padding);
}

/* --- Site Header --- */
.site-header {
  padding: 2rem 0 1rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 3rem;
}

.site-title {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.site-title a {
  color: var(--text);
  text-decoration: none;
}

.site-title a:hover {
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

.site-nav {
  margin-top: 0.75rem;
}

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

.site-nav a {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-decoration: none;
  letter-spacing: 0.03em;
}

.site-nav a:hover {
  color: var(--text);
  text-decoration: underline;
}

.site-nav a[aria-current="page"] {
  color: var(--text);
  font-weight: 600;
}

/* --- Site Footer --- */
.site-footer {
  margin-top: 4rem;
  padding: 2rem 0;
  border-top: 1px solid var(--border);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.site-footer p {
  margin-bottom: 0.35rem;
}

/* --- Page Content --- */
.page-title {
  margin-bottom: 2rem;
}

/* --- Article (Blog Post) --- */
.article-meta {
  font-family: var(--font-sans);
  font-size: 0.85rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.article-content h2:first-child {
  margin-top: 0;
}

.article-nav {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  font-family: var(--font-sans);
  font-size: 0.85rem;
}

.article-nav-prev,
.article-nav-next {
  max-width: 48%;
}

.article-nav-next {
  text-align: right;
  margin-left: auto;
}

.article-nav-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Related Articles --- */
.related-articles {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.related-articles h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 0.75rem;
}

.related-articles ul {
  padding-left: 1.25rem;
}

/* --- Blog List --- */
.blog-list {
  list-style: none;
  padding: 0;
}

.blog-list li {
  margin-bottom: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.blog-list li:last-child {
  border-bottom: none;
}

.blog-list a {
  text-decoration: underline;
}

.blog-list-date {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  color: var(--text-secondary);
  display: block;
  margin-top: 0.15rem;
}

/* --- Contact Grid --- */
.contact-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  margin: 2rem 0;
}

.contact-item h3 {
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-top: 0;
  margin-bottom: 0.35rem;
}

.contact-item p {
  margin-bottom: 0;
  font-size: 1rem;
}

/* --- LINE Button --- */
.line-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--line-green);
  color: #fff;
  text-decoration: none;
  padding: 0.75rem 1.5rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  font-weight: 600;
  border: 2px solid var(--line-green);
  margin-top: 1rem;
  transition: background-color 0.15s, color 0.15s;
}

.line-btn:visited {
  color: #fff;
}

.line-btn:hover,
.line-btn:focus {
  background-color: transparent;
  color: var(--line-green);
  text-decoration: none;
}

.line-btn:hover svg,
.line-btn:focus svg {
  fill: var(--line-green);
}

.line-btn svg {
  width: 1.25rem;
  height: 1.25rem;
  fill: #fff;
  flex-shrink: 0;
  transition: fill 0.15s;
}

/* --- Services --- */
.service-item {
  margin-bottom: 2.5rem;
}

.service-item h2 {
  margin-top: 0;
}

/* --- Copyright Notice (in articles) --- */
.copyright-notice {
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-secondary);
}

/* --- Print Styles --- */
@media print {
  :root {
    --bg: #fff;
    --text: #000;
    --text-secondary: #333;
    --link: #000;
    --border: #ccc;
  }

  html {
    font-size: 12pt;
  }

  body {
    background: #fff;
    color: #000;
  }

  .site-nav,
  .line-btn,
  .article-nav {
    display: none;
  }

  .site-header {
    border-bottom: 1pt solid #000;
    margin-bottom: 1.5rem;
    padding: 0 0 0.5rem;
  }

  .site-footer {
    border-top: 1pt solid #000;
    margin-top: 1.5rem;
  }

  a {
    color: #000;
    text-decoration: underline;
  }

  a[href^="http"]::after {
    content: " (" attr(href) ")";
    font-size: 0.8em;
    font-weight: normal;
  }

  .page-wrapper {
    max-width: 100%;
    padding: 0;
  }
}

/* --- Responsive: Tablet --- */
@media (max-width: 768px) {
  html {
    font-size: 17px;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.4rem;
  }

  .site-header {
    margin-bottom: 2rem;
  }
}

/* --- Responsive: Mobile --- */
@media (max-width: 480px) {
  html {
    font-size: 16px;
  }

  :root {
    --page-padding: 1rem;
  }

  h1 {
    font-size: 1.75rem;
  }

  h2 {
    font-size: 1.3rem;
  }

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

  .contact-grid {
    grid-template-columns: 1fr;
    gap: 1.5rem;
  }

  .article-nav {
    flex-direction: column;
  }

  .article-nav-prev,
  .article-nav-next {
    max-width: 100%;
    text-align: left;
  }
}

/* --- Accessibility --- */
:focus-visible {
  outline: 2px solid var(--link);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
