/*
Theme Name: KaiyiChen Official Theme
Theme URI: https://kaiyichen.com
Author: Kaiyi Chen
Author URI: https://kaiyichen.com
Description: Official WordPress theme for Kaiyi Chen.
Version: 1.0.3
Requires at least: 6.0
Requires PHP: 8.0
Text Domain: kaiyichen-official-theme
*/

:root {
  /* Light mode palette. */
  --theme-light-color-1: #0b4789;
  --theme-light-color-2: #0d3c70;
  --theme-light-color-3: #000000;
  --theme-light-color-4: #ffffff;
  --theme-light-color-5: #ececec;
  --theme-light-color-6: #eeeeee;
  --theme-light-color-7: #fafafa;
  --theme-light-color-8: #ffffffff;

  /* Dark mode palette. */
  --theme-dark-color-1: #0b4789;
  --theme-dark-color-2: #0d3c70;
  --theme-dark-color-3: #ffffff;
  --theme-dark-color-4: #ffffff;
  --theme-dark-color-5: #282a2c;
  --theme-dark-color-6: #eeeeee;
  --theme-dark-color-7: #1a1c1e;
  --theme-dark-color-8: #0e0f11;

  /* Active light-mode semantic tokens. */
  --theme-color-primary: var(--theme-light-color-1);
  --theme-color-primary-hover: var(--theme-light-color-2);
  --theme-color-text: var(--theme-light-color-3);
  --theme-color-surface: var(--theme-light-color-4);
  --theme-color-border: var(--theme-light-color-5);
  --theme-color-text-muted: var(--theme-light-color-6);
  --theme-color-surface-muted: var(--theme-light-color-7);
  --theme-color-overlay: var(--theme-light-color-8);

  /* Typography tokens: minimum → fluid value → desktop maximum. */
  --theme-font-family: "Inter", sans-serif;
  --theme-font-size-h1: clamp(2.5rem, 5vw, 4.5rem);
  --theme-font-size-h2: clamp(2.125rem, 4vw, 3.5rem);
  --theme-font-size-h3: clamp(1.75rem, 3vw, 2.5rem);
  --theme-font-size-h4: clamp(1.5rem, 2.25vw, 2rem);
  --theme-font-size-h5: clamp(1.25rem, 1.75vw, 1.5rem);
  --theme-font-size-h6: clamp(1.125rem, 1.25vw, 1.25rem);
  --theme-font-size-body: clamp(1rem, 0.4vw + 0.9rem, 1.125rem);
  --theme-font-size-button: 1rem;
  --theme-line-height-heading: 1.15;
  --theme-line-height-body: 1.7;
  --theme-line-height-button: 1.25;
  --theme-page-padding: 2.5vw;
  --theme-layout-gap: 1.5rem;
  --theme-menu-angle-color: var(--theme-color-primary);
}

@media (max-width: 1024px) { :root { --theme-page-padding: 5vw; } }
@media (max-width: 767px) { :root { --theme-page-padding: 6vw; } }

@media (prefers-color-scheme: dark) {
  :root {
    --theme-color-primary: var(--theme-dark-color-1);
    --theme-color-primary-hover: var(--theme-dark-color-2);
    --theme-color-text: var(--theme-dark-color-3);
    --theme-color-surface: var(--theme-dark-color-8);
    --theme-color-border: var(--theme-dark-color-5);
    --theme-color-text-muted: var(--theme-dark-color-6);
    --theme-color-surface-muted: var(--theme-dark-color-7);
    --theme-color-overlay: var(--theme-dark-color-4);
  }
}

* { box-sizing: border-box; }

html {
  color-scheme: light dark;
  font-family: var(--theme-font-family);
  overflow-x: hidden;
}

body {
  margin: 0;
  background: var(--theme-color-surface);
  color: var(--theme-color-text);
  font-family: var(--theme-font-family);
  font-size: var(--theme-font-size-body);
  line-height: var(--theme-line-height-body);
  overflow-x: hidden;
}

.site-main, .site-header__middle, .site-footer { padding-inline: var(--theme-page-padding); }
.content-grid { display: grid; gap: var(--theme-layout-gap); }

.single-layout { display: grid; grid-template-columns: 3fr 7fr; gap: var(--theme-layout-gap); }
.single-content { min-width: 0; }
.single-content__body { margin-top: 2rem; }
.author-card { display: flex; gap: 1rem; align-items: flex-start; margin-top: 3rem; padding-top: 2rem; border-top: 1.5px solid var(--theme-color-border); }
.author-card .avatar { width: 4.5rem; height: 4.5rem; border-radius: 50%; }
.author-card__label { margin-bottom: .25rem; color: var(--theme-color-text-muted); font-size: .875rem; }
.author-card h2 { margin-bottom: .5rem; font-size: 1.25rem; }
.comments-area { margin-top: 3rem; padding-top: 2rem; border-top: 1.5px solid var(--theme-color-border); }
.comment-list { display: grid; gap: 1.5rem; margin: 1.5rem 0; padding: 0; list-style: none; }
.comment-body { padding-bottom: 1.5rem; border-bottom: 1px solid var(--theme-color-border); }
.comment-form { display: grid; gap: 1rem; }
.comment-form label { display: block; margin-bottom: .5rem; font-weight: 600; }
.comment-form .form-submit input { width: auto; border-color: var(--theme-color-primary); background: var(--theme-color-primary); color: var(--theme-color-surface); cursor: pointer; }
@media (max-width: 767px) { .single-layout { grid-template-columns: 1fr; } .single-sidebar { display: none; } }

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin-top: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--theme-color-primary);
  font-family: var(--theme-font-family);
  font-weight: 700;
  line-height: var(--theme-line-height-heading);
}

/*
 * Responsive text wrapping system.
 * Titles balance their lines at every available width. Body copy prioritises
 * natural wrapping. The utility class can be applied to any Gutenberg block.
 */
h1,
h2,
h3,
h4,
h5,
h6,
.wp-block-heading,
.theme-auto-break {
  text-wrap: balance;
  overflow-wrap: break-word;
}

p,
.wp-block-paragraph,
.theme-auto-break-copy {
  text-wrap: pretty;
  overflow-wrap: break-word;
}

/* Modern browsers use stricter East Asian line-breaking conventions. */
:lang(zh),
:lang(ja),
:lang(ko) {
  line-break: strict;
  word-break: normal;
}

h1 { font-size: var(--theme-font-size-h1); }
h2 { font-size: var(--theme-font-size-h2); }
h3 { font-size: var(--theme-font-size-h3); }
h4 { font-size: var(--theme-font-size-h4); }
h5 { font-size: var(--theme-font-size-h5); }
h6 { font-size: var(--theme-font-size-h6); }

p {
  font-size: var(--theme-font-size-body);
  line-height: var(--theme-line-height-body);
}

button,
input[type="button"],
input[type="reset"],
input[type="submit"],
.wp-element-button,
.wp-block-button__link {
  font-family: var(--theme-font-family);
  font-size: var(--theme-font-size-button);
  font-weight: 600;
  line-height: var(--theme-line-height-button);
}

.site-header__top { display: grid; grid-template-columns: 7fr 3fr; background: var(--theme-color-primary); color: #fff; }
.site-header__announcements { display: grid; grid-template-columns: auto 1fr; min-width: 0; }
.header-marquee__label, .header-marquee, .site-header__top-nav { padding: .5rem var(--theme-page-padding); }
.header-marquee__label { display: flex; align-items: center; font-size: var(--marquee-size); white-space: nowrap; }
.header-marquee__label::after { width: 1px; height: 1em; margin-left: 10px; content: ""; background: rgb(255 255 255 / 10%); }
.header-marquee { position: relative; overflow: hidden; min-height: 2.5rem; padding-left: 0; text-align: var(--marquee-align); font-size: var(--marquee-size); }
.header-marquee__item { position: absolute; top: 50%; left: 0; display: none; color: #fff; text-decoration: none; transform: translateY(-50%); }
.header-marquee__item.is-active { display: inline-flex; align-items: center; gap: 5px; animation: marquee-slide-up .35s ease both; }
.header-marquee__item::after { width: 1rem; height: 1rem; content: ""; background: #fff; -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 18L18 6M18 6H9M18 6V15' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6 18L18 6M18 6H9M18 6V15' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; }
@keyframes marquee-slide-up { from { opacity: 0; transform: translateY(80%); } to { opacity: 1; transform: translateY(-50%); } }
.header-marquee a, .site-header__top-nav a { color: inherit; text-decoration: none; }
.site-header__top-nav ul { display: flex; justify-content: end; gap: var(--theme-layout-gap); margin: 0; padding: 0; list-style: none; }
form { width: min(100%, var(--theme-form-width, 100%)); }
input, textarea, select { width: 100%; border: 1.5px solid var(--theme-color-border); background: var(--theme-color-surface); color: var(--theme-color-text); padding: .75rem; }
input:focus, textarea:focus, select:focus { border-color: var(--theme-color-primary); outline: none; }
@media (max-width: 767px) { .site-header__top { grid-template-columns: 1fr; } .site-header__top-nav ul { justify-content: center; } }

.site-header__middle {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  min-height: 85px;
  align-items: center;
  justify-content: space-between;
  gap: var(--theme-layout-gap);
  background: var(--theme-color-surface);
  transition: transform .25s ease;
}

.site-header__middle.is-sticky { border-bottom: 1.5px solid var(--theme-color-border); }
.site-header__middle.is-hidden { transform: translateY(-100%); }
.site-header__middle nav .menu { gap: 15px; }

@media (max-width: 767px) {
  .site-header__middle { min-height: 70px; }
}

/* WordPress navigation submenus. */
.site-header__middle nav .menu,
.site-header__top-nav .menu {
  display: flex;
  align-items: center;
  gap: var(--theme-layout-gap);
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-header__middle nav .menu-item,
.site-header__top-nav .menu-item {
  position: relative;
}

.site-header__middle nav .menu-item-has-children > a,
.site-header__top-nav .menu-item-has-children > a { display: inline-flex; align-items: center; gap: .375rem; }
.site-header__middle nav .menu-item-has-children > a::after,
.site-header__top-nav .menu-item-has-children > a::after { width: 1rem; height: 1rem; content: ""; background: var(--theme-menu-angle-color); -webkit-mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19 9L12 15L5 9' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; mask: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M19 9L12 15L5 9' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat; transition: transform .2s ease; }

.site-header__middle nav .sub-menu,
.site-header__top-nav .sub-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + .75rem);
  left: -.75rem;
  display: grid;
  min-width: 13rem;
  gap: .25rem;
  margin: 0;
  padding: .5rem;
  list-style: none;
  border: 1px solid var(--theme-color-border);
  background: var(--theme-color-surface);
  box-shadow: 0 .75rem 1.5rem rgb(0 0 0 / 12%);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-.5rem);
  transition: opacity .2s ease, transform .2s ease;
}

.site-header__middle nav .menu-item:hover > .sub-menu,
.site-header__middle nav .menu-item:focus-within > .sub-menu,
.site-header__top-nav .menu-item:hover > .sub-menu,
.site-header__top-nav .menu-item:focus-within > .sub-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
.site-header__middle nav .menu-item-has-children:hover > a::after, .site-header__middle nav .menu-item-has-children:focus-within > a::after, .site-header__top-nav .menu-item-has-children:hover > a::after, .site-header__top-nav .menu-item-has-children:focus-within > a::after { transform: rotate(180deg); }

.site-header__middle nav .sub-menu a,
.site-header__top-nav .sub-menu a {
  display: block;
  padding: .625rem .75rem;
  color: var(--theme-color-text);
  text-decoration: none;
}

.site-header__middle nav .sub-menu a:hover,
.site-header__middle nav .sub-menu a:focus {
  background: var(--theme-color-surface-muted);
  color: var(--theme-color-primary);
}

@media (max-width: 767px) {
  .site-header__middle nav .menu,
  .site-header__top-nav .menu {
    flex-wrap: wrap;
    justify-content: center;
  }

  .site-header__middle nav .sub-menu,
  .site-header__top-nav .sub-menu {
    position: static;
    display: grid;
    min-width: 0;
    margin-top: .5rem;
    opacity: 1;
    pointer-events: auto;
    transform: none;
    box-shadow: none;
  }
}
