/*
Theme Name: Stormy Book Theme
Theme URI: https://example.com/stormy-book-theme
Author: Stormy
Description: A classic WordPress theme with palette presets, light/dark/system mode, and a responsive right sidebar.
Version: 1.0.0
License: GNU General Public License v2 or later
Text Domain: stormy-book-theme
*/

:root {
  --stormy-background: 45 30% 97%;
  --stormy-foreground: 30 20% 15%;
  --stormy-surface: 45 40% 98%;
  --stormy-surface-strong: 45 44% 99%;
  --stormy-surface-muted: 45 28% 96%;
  --stormy-surface-overlay: 45 35% 92%;
  --stormy-surface-border: 35 25% 84%;
  --stormy-surface-shadow: 30 20% 20%;
  --stormy-primary: 25 80% 45%;
  --stormy-primary-foreground: 45 30% 98%;
  --stormy-secondary: 180 25% 35%;
  --stormy-secondary-foreground: 45 30% 98%;
  --stormy-accent: 35 70% 55%;
  --stormy-accent-foreground: 30 20% 15%;
  --stormy-muted: 40 20% 90%;
  --stormy-muted-foreground: 30 15% 45%;
  --stormy-destructive: 0 70% 50%;
  --stormy-destructive-foreground: 0 0% 98%;
  --stormy-border: 35 25% 85%;
  --stormy-input: 35 25% 85%;
  --stormy-ring: 25 80% 45%;
  --stormy-link: var(--stormy-primary);
  --stormy-link-hover: var(--stormy-accent);
  --stormy-code-bg: 40 24% 93%;
  --stormy-code-fg: 30 20% 20%;
  --stormy-sidebar-background: 40 25% 95%;
  --stormy-sidebar-foreground: 30 20% 20%;
  --stormy-sidebar-primary: 25 80% 45%;
  --stormy-sidebar-primary-foreground: 45 30% 98%;
  --stormy-sidebar-accent: 35 30% 90%;
  --stormy-sidebar-accent-foreground: 30 20% 15%;
  --stormy-sidebar-border: 35 25% 85%;
  --stormy-sidebar-ring: 25 80% 45%;
  --stormy-radius: 1.25rem;
  --stormy-page-width: min(1280px, calc(100vw - 2rem));
  --stormy-sidebar-width: clamp(280px, 27vw, 360px);
}

html {
  background:
    radial-gradient(circle at 15% 0%, hsl(var(--stormy-primary) / 0.12), transparent 30%),
    radial-gradient(circle at 85% 10%, hsl(var(--stormy-accent) / 0.10), transparent 28%),
    linear-gradient(180deg, hsl(var(--stormy-background)), hsl(var(--stormy-background)));
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: hsl(var(--stormy-foreground));
  background:
    radial-gradient(circle at 15% 0%, hsl(var(--stormy-primary) / 0.09), transparent 30%),
    radial-gradient(circle at 85% 10%, hsl(var(--stormy-accent) / 0.08), transparent 28%),
    linear-gradient(180deg, hsl(var(--stormy-background)), hsl(var(--stormy-background)));
}

a {
  color: hsl(var(--stormy-link));
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

a:hover,
a:focus-visible {
  color: hsl(var(--stormy-link-hover));
}

img,
video,
iframe {
  max-width: 100%;
}

code,
pre,
kbd,
samp {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

pre {
  overflow-x: auto;
  padding: 1rem;
  border-radius: 1rem;
  background: hsl(var(--stormy-code-bg));
  color: hsl(var(--stormy-code-fg));
  border: 1px solid hsl(var(--stormy-border));
}

code {
  padding: 0.15rem 0.35rem;
  border-radius: 0.5rem;
  background: hsl(var(--stormy-code-bg));
  color: hsl(var(--stormy-code-fg));
}

::selection {
  background: hsl(var(--stormy-primary) / 0.22);
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  background: linear-gradient(180deg, hsl(var(--stormy-surface-strong) / 0.92), hsl(var(--stormy-surface) / 0.82));
  border-bottom: 1px solid hsl(var(--stormy-border) / 0.7);
}

.site-header__inner,
.site-footer__inner {
  width: var(--stormy-page-width);
  margin: 0 auto;
  padding: 1rem;
}

.site-header__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

.site-brand__mark {
  width: 2.75rem;
  height: 2.75rem;
  flex: 0 0 auto;
  border-radius: 0.9rem;
  background: linear-gradient(135deg, hsl(var(--stormy-primary)), hsl(var(--stormy-accent)));
  box-shadow: 0 12px 26px -16px hsl(var(--stormy-primary) / 0.7);
}

.site-title {
  margin: 0;
  font-size: clamp(1.15rem, 1.8vw, 1.65rem);
  line-height: 1.05;
}

.site-title a {
  color: inherit;
  text-decoration: none;
}

.site-description {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  color: hsl(var(--stormy-muted-foreground));
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 0.75rem;
}

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

.site-nav li {
  margin: 0;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 2.5rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  color: hsl(var(--stormy-foreground));
  text-decoration: none;
}

.site-nav a:hover,
.site-nav .current-menu-item > a,
.site-nav .current_page_item > a {
  background: hsl(var(--stormy-primary) / 0.12);
  color: hsl(var(--stormy-primary));
}

.site-shell {
  width: var(--stormy-page-width);
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
  display: grid;
  gap: 1.5rem;
}

.site-main,
.site-sidebar {
  min-width: 0;
}

.site-sidebar {
  order: 2;
}

@media (min-width: 1100px) {
  .site-shell {
    grid-template-columns: minmax(0, 1fr) var(--stormy-sidebar-width);
    align-items: start;
  }

  .site-sidebar {
    order: 0;
    position: sticky;
    top: 5.75rem;
  }
}

.site-main .entry,
.site-main .page,
.site-main .search-result,
.site-main .no-results,
.site-sidebar .widget,
.site-sidebar .wp-block-group,
.site-sidebar .wp-block-search,
.site-sidebar .wp-block-latest-posts,
.site-sidebar .wp-block-categories,
.site-sidebar .wp-block-archives,
.site-sidebar .wp-block-calendar {
  background: linear-gradient(180deg, hsl(var(--stormy-surface-strong) / 0.92), hsl(var(--stormy-surface) / 0.82));
  border: 1px solid hsl(var(--stormy-border) / 0.8);
  border-radius: var(--stormy-radius);
  box-shadow: 0 28px 60px -36px hsl(var(--stormy-surface-shadow) / 0.28);
}

.entry,
.page,
.search-result,
.no-results {
  padding: clamp(1rem, 2vw, 1.5rem);
}

.entry + .entry,
.search-result + .search-result {
  margin-top: 1rem;
}

.entry-title,
.page-title,
.archive-title,
.search-title {
  margin: 0 0 0.5rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.entry-meta,
.archive-description,
.search-description {
  color: hsl(var(--stormy-muted-foreground));
  font-size: 0.95rem;
}

.entry-content > * + *,
.page-content > * + *,
.widget > * + * {
  margin-top: 1rem;
}

.entry-content h2,
.entry-content h3,
.entry-content h4,
.page-content h2,
.page-content h3,
.page-content h4 {
  scroll-margin-top: 7rem;
}

.wp-block-button__link,
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: 0.65rem 1rem;
  border: 1px solid transparent;
  border-radius: 999px;
  background: hsl(var(--stormy-primary));
  color: hsl(var(--stormy-primary-foreground));
  text-decoration: none;
  font: inherit;
  cursor: pointer;
}

.wp-block-button__link:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
  filter: brightness(1.03);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="password"],
input[type="search"],
input[type="tel"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: 2.75rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid hsl(var(--stormy-border));
  border-radius: 0.95rem;
  background: hsl(var(--stormy-surface-strong));
  color: inherit;
}

textarea {
  min-height: 9rem;
}

.site-footer {
  border-top: 1px solid hsl(var(--stormy-border) / 0.7);
  background: hsl(var(--stormy-surface-strong) / 0.68);
}

.site-footer p {
  margin: 0;
  color: hsl(var(--stormy-muted-foreground));
}

.widget {
  padding: 1.1rem;
}

.widget-title,
.wp-block-group__inner-container > h2,
.wp-block-group__inner-container > h3 {
  margin-top: 0;
  margin-bottom: 0.85rem;
}

.widget ul,
.wp-block-latest-posts,
.wp-block-categories,
.wp-block-archives {
  list-style: none;
  padding-left: 0;
  margin-left: 0;
}

.widget li + li,
.wp-block-latest-posts li + li,
.wp-block-categories li + li,
.wp-block-archives li + li {
  margin-top: 0.6rem;
}

.alignwide {
  margin-left: calc(50% - min(50vw, 640px));
  margin-right: calc(50% - min(50vw, 640px));
}

.alignfull {
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
}

@media (max-width: 1099px) {
  .site-header__bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .site-nav {
    width: 100%;
  }
}

@media (max-width: 719px) {
  .site-shell {
    padding-top: 1rem;
    gap: 1rem;
  }

  .site-header__inner,
  .site-footer__inner {
    padding-inline: 0.75rem;
  }

  .site-brand {
    align-items: flex-start;
  }

  .site-brand__mark {
    width: 2.25rem;
    height: 2.25rem;
  }

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

  .site-nav a {
    width: 100%;
  }
}

/*
 * Plugin-friendly baseline surfaces
 */
.wp-block,
.wp-block-group,
.wp-block-columns,
.wp-block-cover,
.wp-block-media-text,
.wp-block-search,
.wp-block-latest-posts,
.wp-block-archives,
.wp-block-categories,
.wp-block-calendar,
.wp-block-table,
.wp-block-quote,
.wp-block-code,
.wp-caption,
.gallery-item,
.comment-body,
.comment-respond,
.navigation,
.post-navigation,
.pagination,
.is-style-default {
  border-radius: var(--stormy-radius);
}

.wp-block-table table,
table {
  width: 100%;
  border-collapse: collapse;
}

.wp-block-table th,
.wp-block-table td,
th,
td {
  border: 1px solid hsl(var(--stormy-border));
  padding: 0.75rem;
  text-align: left;
}

.wp-block-quote,
blockquote {
  padding: 1rem 1.25rem;
  border-left: 4px solid hsl(var(--stormy-primary));
  background: hsl(var(--stormy-surface-muted));
}
