/* ========================================
   Editorial Apple-inspired theme for noppe.dev
   ======================================== */

:root {
  color-scheme: light dark;
  --page-background: #ffffff;
  --surface-background: #f5f5f7;
  --surface-elevated: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --border-color: rgba(0, 0, 0, 0.09);
  --border-strong: rgba(0, 0, 0, 0.14);
  --link-color: #0066cc;
  --link-hover: #0071e3;
  --control-fill: #0071e3;
  --control-text: #0071e3;
  --control-focus: rgba(0, 125, 250, 0.6);
  --footer-background: #f5f5f7;
  --footer-text: #515154;
  --header-background: rgba(255, 255, 255, 0.78);
  --selection-background: rgba(0, 102, 204, 0.18);
  --image-shadow: 0 18px 44px rgba(0, 0, 0, 0.09), 0 2px 8px rgba(0, 0, 0, 0.04);
  --content-width: 1160px;
  --reading-width: 800px;
  --page-gutter: clamp(20px, 5vw, 56px);
  --radius-small: 12px;
  --radius-medium: 20px;
  --radius-large: 28px;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, Meiryo, sans-serif;
  --font-ui: "SF Pro Text", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --transition-color: color 160ms ease;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page-background: #000000;
    --surface-background: #1c1c1e;
    --surface-elevated: #2c2c2e;
    --text-primary: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #8e8e93;
    --border-color: rgba(255, 255, 255, 0.14);
    --border-strong: rgba(255, 255, 255, 0.22);
    --link-color: #2997ff;
    --link-hover: #64b5ff;
    --control-fill: #0071e3;
    --control-text: #2997ff;
    --footer-background: #1d1d1f;
    --footer-text: #a1a1a6;
    --header-background: rgba(0, 0, 0, 0.78);
    --selection-background: rgba(41, 151, 255, 0.28);
    --image-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(0, 0, 0, 0.28);
  }
}

:root[data-theme="dark"] {
  --page-background: #000000;
  --surface-background: #1c1c1e;
  --surface-elevated: #2c2c2e;
  --text-primary: #f5f5f7;
  --text-secondary: #a1a1a6;
  --text-tertiary: #8e8e93;
  --border-color: rgba(255, 255, 255, 0.14);
  --border-strong: rgba(255, 255, 255, 0.22);
  --link-color: #2997ff;
  --link-hover: #64b5ff;
  --control-fill: #0071e3;
  --control-text: #2997ff;
  --footer-background: #1d1d1f;
  --footer-text: #a1a1a6;
  --header-background: rgba(0, 0, 0, 0.78);
  --selection-background: rgba(41, 151, 255, 0.28);
  --image-shadow: 0 18px 44px rgba(0, 0, 0, 0.42), 0 2px 8px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  background: var(--page-background);
  color: var(--text-primary);
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-width: 320px;
  margin: 0;
  background: var(--page-background);
  color: var(--text-primary);
}

.page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100svh;
  font-family: var(--font-sans);
  font-size: 17px;
  line-height: 1.75;
  letter-spacing: 0.005em;
  font-optical-sizing: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 52px;
  padding: 0 var(--page-gutter);
  border-bottom: 1px solid var(--border-color);
  background: var(--header-background);
  box-shadow: 0 1px 12px rgba(0, 0, 0, 0.025);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
}

.header__link,
.header__link:hover,
.header__link:focus,
.header__link:active,
.header__link:visited {
  color: var(--text-primary);
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.015em;
  text-decoration: none;
}

.site-footer-wrapper {
  background: var(--footer-background);
}

.site-footer {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 22px 24px;
  box-sizing: content-box;
  color: var(--footer-text);
  font-family: var(--font-ui);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.45;
}

.site-footer__inner {
  display: flex;
  align-items: flex-end;
  flex-flow: row wrap;
  justify-content: flex-end;
  padding-top: 17px;
}

.site-footer__copyright {
  flex: 1 0 50%;
  margin: 0 0 8px;
  padding-right: 8px;
  color: var(--footer-text);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.333337;
  letter-spacing: -0.01em;
}

.site-footer__controls {
  margin-bottom: 8px;
}

.theme-picker {
  --toggle-color-fill: var(--control-fill);
  --toggle-color-text: var(--control-text);
  --toggle-border-radius-outer: 12px;
  --toggle-border-radius-inner: 10px;
  display: inline-flex;
  padding: 1px;
  border: 1px solid var(--toggle-color-fill);
  border-radius: var(--toggle-border-radius-outer);
  font-family: var(--font-ui);
  font-size: 0.7058823529rem;
  font-weight: 400;
  line-height: 1.3333733333;
  letter-spacing: -0.01em;
}

.theme-picker__option {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  padding: 1px 6px;
  border: 1px solid transparent;
  border-radius: var(--toggle-border-radius-inner);
  background: transparent;
  color: var(--toggle-color-text);
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.theme-picker__option:hover {
  cursor: pointer;
}

.theme-picker__option[aria-pressed="true"] {
  border-color: var(--toggle-color-fill);
  background: var(--toggle-color-fill);
  color: #ffffff;
}

.theme-picker__option:focus-visible {
  outline: 4px solid var(--control-focus);
  outline-offset: 1px;
}

@media only screen and (max-width: 735px) {
  .site-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
}

.page-body {
  flex: 1 0 auto;
  width: 100%;
  max-width: var(--content-width);
  margin: 0 auto;
  padding: 28px var(--page-gutter) 128px;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  max-width: var(--reading-width);
  margin: 0 auto;
  color: var(--text-tertiary);
  font-size: 13px;
  line-height: 1.5;
}

.breadcrumbs a {
  color: var(--text-secondary);
}

.notion-content {
  width: 100%;
  color: var(--text-primary);
}

.notion-content > *:not(.article-header) {
  max-width: var(--reading-width);
  margin-right: auto;
  margin-left: auto;
}

.wide-page > *:not(.article-header) {
  max-width: var(--content-width);
}

.index-page {
  display: block;
  padding-top: clamp(28px, 5vw, 64px);
}

.index-page > *:not(.article-header) {
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

.index-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2fr);
  column-gap: clamp(32px, 8vw, 128px);
  row-gap: 0;
}

.index-section + .index-section {
  margin-top: clamp(96px, 12vw, 160px);
}

.index-section__heading {
  grid-column: 1;
  align-self: start;
  margin: 0 0 28px;
  font-size: clamp(36px, 4vw, 56px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.index-section__item {
  grid-column: 2;
  margin: 0;
  padding: 19px 0 18px;
  border-top: 1px solid var(--border-color);
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.3;
}

.index-section__item--last {
  border-bottom: 1px solid var(--border-color);
}

.index-section__item a {
  color: var(--text-primary);
  font-weight: 600;
}

.index-section__item a:hover {
  color: var(--link-color);
  text-decoration: none;
}

.social-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 32px;
  margin-bottom: 0;
}

.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text-tertiary);
  text-decoration: none;
  transition: var(--transition-color);
}

.icon-link:hover {
  color: var(--link-color);
  text-decoration: none;
}

.icon-link:focus-visible {
  border-radius: 6px;
  outline: 4px solid var(--control-focus);
  outline-offset: 1px;
}

.icon-link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

.profile-page {
  padding-top: clamp(32px, 7vw, 96px);
}

.profile-page > *:not(.article-header) {
  max-width: none;
  margin-right: 0;
  margin-left: 0;
}

.profile-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(32px, 8vw, 112px);
  max-width: var(--reading-width);
  margin: 0 auto;
}

.profile-identity {
  flex: 1 1 auto;
}

.profile-portrait {
  flex: 0 0 clamp(220px, 32vw, 360px);
  width: clamp(220px, 32vw, 360px);
  margin: 0 !important;
}

.profile-portrait img {
  display: block;
  width: 100%;
  margin: 0;
  border-radius: 0;
  box-shadow: none;
}

.profile-name {
  margin: 0;
  font-size: clamp(42px, 5vw, 64px);
  line-height: 1.05;
  letter-spacing: -0.045em;
}

.profile-role {
  margin: 12px 0 0;
  color: var(--text-secondary);
  font-size: clamp(20px, 2vw, 28px);
  line-height: 1.3;
}

.profile-message {
  max-width: var(--reading-width);
  margin: clamp(96px, 13vw, 176px) auto 0;
}

.profile-message__title {
  margin: 0 0 24px;
  color: var(--text-tertiary);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.profile-message__text {
  max-width: 640px;
  margin: 0;
  font-size: clamp(22px, 3vw, 32px);
  line-height: 1.35;
  letter-spacing: -0.02em;
}

.profile-message > .social-links {
  margin-top: 28px;
}

.article-header {
  max-width: 1040px;
  margin: 0 auto;
  padding: clamp(56px, 10vw, 112px) 0 clamp(48px, 7vw, 80px);
  text-align: center;
}

.article-title {
  margin: 0;
  color: var(--text-primary);
  font-size: clamp(38px, 5.5vw, 64px);
  font-weight: 700;
  line-height: 1.08;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.notion-text,
.notion-content p {
  color: var(--text-primary);
}

.notion-content > p {
  margin-top: 1.2em;
  margin-bottom: 1.2em;
}

.notion-callout {
  margin-top: 32px;
  margin-bottom: 32px;
  padding: 20px 22px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--surface-background);
}

h1,
h2,
h3 {
  color: var(--text-primary);
  font-weight: 700;
  text-wrap: balance;
}

h1 {
  margin-top: 80px;
  margin-bottom: 28px;
  font-size: clamp(36px, 5vw, 52px);
  line-height: 1.1;
  letter-spacing: -0.04em;
}

h2 {
  margin-top: 72px;
  margin-bottom: 24px;
  font-size: clamp(27px, 3.8vw, 34px);
  line-height: 1.2;
  letter-spacing: -0.032em;
}

h3 {
  margin-top: 48px;
  margin-bottom: 16px;
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}

a {
  color: var(--link-color);
  text-decoration: none;
  transition: color 160ms ease, opacity 160ms ease;
}

a:hover {
  color: var(--link-hover);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

a:active {
  opacity: 0.65;
}

strong,
b {
  color: var(--text-primary);
  font-weight: 650;
}

ul,
ol {
  padding-left: 1.45em;
}

li {
  margin: 0.45em 0;
}

li::marker {
  color: var(--text-tertiary);
}

blockquote {
  margin-top: 36px;
  margin-bottom: 36px;
  padding: 18px 24px;
  border-left: 3px solid var(--text-primary);
  border-radius: 0 var(--radius-medium) var(--radius-medium) 0;
  background: var(--surface-background);
  color: var(--text-secondary);
  font-size: 1.02em;
  line-height: 1.7;
}

hr {
  max-width: var(--reading-width);
  margin-top: 64px;
  margin-bottom: 64px;
  border: 0;
  border-top: 1px solid var(--border-color);
}

code {
  padding: 0.15em 0.4em;
  border: 1px solid var(--border-color);
  border-radius: 7px;
  background: var(--surface-background);
  font-family: var(--font-mono);
  font-size: 0.88em;
}

pre {
  max-width: 900px !important;
  overflow-x: auto;
  margin-top: 36px;
  margin-bottom: 36px;
  padding: 24px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--surface-background);
  line-height: 1.65;
}

pre code {
  padding: 0;
  border: 0;
  background: transparent;
}

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

.notion-content > p:has(> img:only-child),
figure {
  max-width: var(--content-width) !important;
  margin-top: clamp(40px, 7vw, 72px);
  margin-bottom: clamp(40px, 7vw, 72px);
}

.notion-content > p:has(> img:only-child) img,
figure img {
  display: block;
  margin-right: auto;
  margin-left: auto;
  border-radius: var(--radius-large);
  box-shadow: var(--image-shadow);
}

figcaption {
  max-width: var(--reading-width);
  margin: 12px auto 0;
  color: var(--text-secondary);
  font-size: 13px;
  line-height: 1.5;
  text-align: center;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-small);
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}

th {
  background: var(--surface-background);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

tr:last-child td {
  border-bottom: 0;
}

.notion-gallery-view .notion-collection-view-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.notion-collection-card {
  overflow: hidden;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-medium);
  background: var(--surface-elevated);
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}

.notion-collection-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08), 0 2px 6px rgba(0, 0, 0, 0.04);
}

.collection-list {
  display: grid;
  gap: 0;
  margin-top: 20px;
  margin-bottom: 48px;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--border-color);
}

.collection-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin: 0;
  padding: 16px 0;
  border-bottom: 1px solid var(--border-color);
}

.collection-list a {
  color: var(--text-primary);
  font-weight: 600;
}

.collection-list a:hover {
  color: var(--link-color);
}

.collection-list__meta {
  flex: 0 0 auto;
  color: var(--text-tertiary);
  font-size: 13px;
}

::selection {
  background: var(--selection-background);
}

@media (prefers-reduced-transparency: reduce) {
  .site-header {
    background: var(--surface-elevated);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  a,
  .icon-link,
  .notion-collection-card {
    transition: none;
  }

  .notion-collection-card:hover {
    transform: none;
  }
}

@media screen and (max-width: 600px) {
  .page {
    font-size: 16px;
    line-height: 1.72;
  }

  .site-header {
    min-height: 48px;
  }

  .header__link {
    font-size: 16px;
  }

  .page-body {
    padding-top: 20px;
    padding-bottom: 88px;
  }

  .article-header {
    padding-top: 48px;
    padding-bottom: 44px;
  }

  .article-title {
    font-size: 38px;
    letter-spacing: -0.04em;
  }

  .index-page {
    display: block;
    padding-top: 0;
  }

  .profile-page {
    padding-top: 24px;
  }

  .profile-header {
    gap: 24px;
  }

  .profile-portrait {
    flex: 0 0 min(42vw, 220px);
    width: min(42vw, 220px);
  }

  .profile-portrait img {
    width: 100%;
  }

  .profile-name {
    font-size: 42px;
  }

  .profile-role {
    margin-top: 10px;
    font-size: 22px;
  }

  .profile-message {
    margin-top: 80px;
  }

  .profile-message__text {
    font-size: 22px;
  }

  .index-section {
    display: block;
  }

  .index-section + .index-section {
    margin-top: 88px;
  }

  .index-section__heading {
    margin-bottom: 24px;
  }

  .index-section__item {
    padding-top: 16px;
    padding-bottom: 15px;
  }

  h1 {
    margin-top: 56px;
    font-size: 34px;
  }

  h2 {
    margin-top: 56px;
    font-size: 28px;
  }

  h3 {
    margin-top: 40px;
    font-size: 21px;
  }

  .notion-content > p:has(> img:only-child),
  figure {
    margin-top: 40px;
    margin-bottom: 40px;
  }

  .notion-content > p:has(> img:only-child) img,
  figure img {
    border-radius: var(--radius-medium);
  }

  .collection-list li {
    align-items: flex-start;
    flex-direction: column;
    gap: 2px;
  }

  pre {
    margin-right: -8px;
    margin-left: -8px;
    padding: 18px;
    border-radius: 14px;
  }
}
