/*
Theme Name: Notes from the Cosmos
Theme URI: https://github.com/chriswdixon/chriswdixon.com
Author: Chris Dixon
Author URI: https://chriswdixon.com
Description: Custom theme for chriswdixon.com. Dark, space-y, deployed from GitHub. Do not edit in wp-admin; the repo is the source of truth.
Version: 1.2.0
Requires at least: 6.4
Requires PHP: 8.1
License: MIT
Text Domain: cosmos
*/

/* WordPress-specific styles layered on top of assets/app.css
   (the compiled stylesheet from the original site). */

/* 3D starfield background (assets/space.js injects #cosmos-space).
   Sits behind all content; content is lifted into its own layer so the
   stars never intercept clicks or sit on top of text. */
#cosmos-space {
    position: fixed;
    inset: 0;
    z-index: 0;
    display: block;
    pointer-events: none;
    /* Transparent canvas composites over the body's dark gradient. */
}
body > .min-h-screen {
    position: relative;
    z-index: 1;
}

/* Comment list */
.cosmos-comment {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    list-style: none;
}
.cosmos-comment .comment-meta {
    display: flex;
    align-items: baseline;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}
.cosmos-comment .comment-author {
    color: var(--foreground);
    font-weight: 500;
    font-size: 0.875rem;
}
.cosmos-comment .comment-author a {
    color: var(--primary);
    text-decoration: none;
}
.cosmos-comment .comment-body p {
    font-size: 0.875rem;
    line-height: 1.6;
    margin: 0 0 0.5rem;
}
.cosmos-comment .children {
    margin: 1rem 0 0;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
}
.cosmos-comment .reply a,
.cosmos-comment .comment-edit-link {
    font-size: 0.75rem;
    color: var(--primary);
    text-decoration: none;
}
.comment-awaiting-moderation {
    font-size: 0.75rem;
    color: var(--accent);
    display: block;
    margin-bottom: 0.5rem;
}

/* Comment form: match the site's input styling without relying on
   Tailwind utility classes WordPress can't add itself. */
.comment-form input[type="text"],
.comment-form input[type="email"],
.comment-form input[type="url"],
.comment-form textarea {
    display: flex;
    width: 100%;
    border-radius: 0.375rem;
    border: 1px solid var(--input);
    background: transparent;
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
    color: var(--foreground);
    font-family: var(--font-body);
    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}
.comment-form input:focus-visible,
.comment-form textarea:focus-visible {
    outline: none;
    box-shadow: 0 0 0 1px var(--ring);
}
.comment-form ::placeholder { color: var(--muted-foreground); }
.comment-form p { margin-bottom: 0.75rem; }
.comment-form label { display: none; }
.comment-form .comment-notes,
.comment-form .logged-in-as {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}
.comment-form .submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
    border: none;
    background: var(--primary);
    color: var(--primary-foreground);
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: opacity 0.2s;
}
.comment-form .submit:hover { opacity: 0.9; }

/* Pagination */
.cosmos-pagination {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin: 3rem 0 0;
    font-size: 0.875rem;
}
.cosmos-pagination .page-numbers {
    padding: 0.375rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 9999px;
    color: var(--foreground);
    text-decoration: none;
    transition: border-color 0.2s, color 0.2s;
}
.cosmos-pagination .page-numbers:hover { border-color: var(--primary); color: var(--primary); }
.cosmos-pagination .page-numbers.current {
    background: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

/* Core block sanity inside post content */
.prose-blog .wp-block-image img { border-radius: 0.5rem; max-width: 100%; height: auto; }
.prose-blog figure { margin: 1rem 0; }
.prose-blog figcaption { font-size: 0.75rem; color: var(--muted-foreground); text-align: center; margin-top: 0.5rem; }
.prose-blog .wp-block-code { border: 1px solid var(--border); background: #020309; border-radius: 0.5rem; padding: 1rem; overflow-x: auto; }

/* Screen-reader text (WP requirement) */
.screen-reader-text {
    clip-path: inset(50%);
    height: 1px;
    width: 1px;
    overflow: hidden;
    position: absolute !important;
    word-wrap: normal !important;
}

/* Public watchlist (/watchlist/). Plain CSS on the theme's variables, because
   assets/app.css is precompiled Tailwind and only holds the utilities the old
   theme happened to use. Filled in by assets/watchlist.js. */
.cwd-wl-count { color: var(--muted-foreground); font-size: 0.875rem; margin-bottom: 1.5rem; }
.cwd-wl-empty { color: var(--muted-foreground); }
.cwd-wl-folder {
	font-family: var(--font-display, inherit);
	font-size: 1.25rem;
	font-weight: 400;
	letter-spacing: -0.01em;
	margin: 1rem 0 0.25rem;
	color: var(--foreground);
}
.cwd-wl-folder:focus { outline: none; }
.cwd-wl-grid {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	gap: 1.25rem;
	grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
.cwd-wl-card {
	display: flex;
	flex-direction: column;
	border: 1px solid var(--border);
	border-radius: 0.5rem;
	overflow: hidden;
	background: var(--card);
	box-shadow: var(--shadow-elegant);
	transition: border-color 0.2s, transform 0.2s;
}
.cwd-wl-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.cwd-wl-poster { aspect-ratio: 2 / 3; background: rgba(255, 255, 255, 0.04); overflow: hidden; }
.cwd-wl-poster img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cwd-wl-noposter {
	display: flex; align-items: center; justify-content: center; height: 100%;
	padding: 1rem; text-align: center; font-size: 0.875rem; color: var(--muted-foreground);
}
.cwd-wl-body { padding: 0.25rem 0.75rem 0.75rem; display: flex; flex-direction: column; gap: 0.25rem; }
.cwd-wl-title { display: block; padding: 0.75rem 0.75rem 0; font-size: 0.9375rem; font-weight: 500; line-height: 1.3; color: var(--foreground); }
.cwd-wl-meta { font-size: 0.75rem; color: var(--muted-foreground); margin: 0; }
.cwd-wl-label {
	font-size: 0.625rem; text-transform: uppercase; letter-spacing: 0.1em;
	color: var(--muted-foreground); margin: 0.5rem 0 0;
}
.cwd-wl-services { display: flex; flex-wrap: wrap; gap: 0.375rem; }
.cwd-wl-service { display: inline-flex; border-radius: 0.375rem; overflow: hidden; line-height: 0; }
.cwd-wl-service img { width: 32px; height: 32px; display: block; }
a.cwd-wl-service:hover, a.cwd-wl-service:focus-visible { outline: 2px solid var(--primary); outline-offset: 1px; }
.cwd-wl-service-name { font-size: 0.75rem; line-height: 1.4; padding: 0.125rem 0.375rem; border: 1px solid var(--border); }
.cwd-wl-attribution { margin-top: 3rem; font-size: 0.75rem; color: var(--muted-foreground); }

/* ScreenStack, signed out: the public list inside the app chrome. */
.ss-public-list { max-width: 72rem; margin: 0 auto; padding: 3rem 1rem; }
.ss-public-head { margin-bottom: 2rem; }

/* The card's open button: poster and title, reset to look like the card. */
.cwd-wl-open {
	display: block; width: 100%; padding: 0; margin: 0; border: 0; background: none;
	color: inherit; font: inherit; text-align: left; cursor: pointer;
}
.cwd-wl-open:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.cwd-wl-card:focus-within { border-color: var(--primary); }

/* Details view. */
.cwd-wl-dialog {
	/* A modal <dialog> centres itself with margin: auto, and the precompiled
	   Tailwind reset in app.css zeroes every margin, pinning it top left. */
	margin: auto;
	width: min(56rem, calc(100vw - 2rem)); max-height: calc(100dvh - 2rem);
	padding: 0; border: 1px solid var(--border); border-radius: 0.75rem;
	/* --card is translucent glass; a dialog over a busy grid needs a solid ground. */
	background: var(--background); color: var(--foreground); box-shadow: var(--shadow-elegant);
	overflow: auto;
}
.cwd-wl-dialog::backdrop { background: rgba(0, 0, 0, 0.7); }
.cwd-wl-dialog-body { display: grid; grid-template-columns: minmax(0, 14rem) minmax(0, 1fr); gap: 1.5rem; padding: 1.5rem; }
.cwd-wl-dialog-poster { width: 100%; height: auto; border-radius: 0.5rem; }
.cwd-wl-dialog-info { display: flex; flex-direction: column; gap: 0.375rem; min-width: 0; }
.cwd-wl-dialog-title { font-family: var(--font-display, inherit); font-size: 1.75rem; font-weight: 400; line-height: 1.2; margin: 0 2.5rem 0 0; }
.cwd-wl-overview { margin: 0; line-height: 1.6; }
.cwd-wl-trailer { position: relative; aspect-ratio: 16 / 9; margin-top: 0.25rem; }
.cwd-wl-trailer iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; border-radius: 0.5rem; }
.cwd-wl-close {
	position: sticky; top: 0.75rem; float: right; margin: 0.75rem 0.75rem 0 0; z-index: 1;
	width: 2.25rem; height: 2.25rem; border-radius: 999px; border: 1px solid var(--border);
	background: var(--background); color: var(--foreground); font-size: 1.25rem; line-height: 1; cursor: pointer;
}
.cwd-wl-close:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }
@media (max-width: 640px) {
	.cwd-wl-dialog-body { grid-template-columns: 1fr; padding: 1rem; }
	.cwd-wl-dialog-poster { max-width: 10rem; }
}
@media (prefers-reduced-motion: reduce) {
	.cwd-wl-card { transition: none; }
	.cwd-wl-card:hover { transform: none; }
}

/* Post cards: the title link covers the whole card; badge and tag links sit
   above it so they stay clickable. See renderCard(). */
.cwd-card { position: relative; }
.cwd-card-link { color: inherit; }
.cwd-card-link::after { content: ""; position: absolute; inset: 0; z-index: 0; }
.cwd-card a:not(.cwd-card-link) { position: relative; z-index: 1; }
.cwd-card-link:focus-visible { outline: none; }
.cwd-card:has(.cwd-card-link:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

/* Active filter chip: white on the brand blue is 3.47:1, under the 4.5:1
   WCAG AA needs for small text. One step darker clears it (4.6:1). */
.cwd-pill.bg-primary { background-color: #0a6fd6; border-color: #0a6fd6; }

/* Franchise folder tile: a poster collage with a stacked-card edge, so it
   reads as "several titles in here" at a glance. */
.cwd-wl-folder-tile { box-shadow: 6px -6px 0 -1px var(--card), 6px -6px 0 0 var(--border), var(--shadow-elegant); margin: 6px 6px 0 0; }
.cwd-wl-folder-art { position: relative; }
.cwd-wl-collage { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; gap: 2px; height: 100%; background: var(--border); }
.cwd-wl-collage.is-single { grid-template-columns: 1fr; grid-template-rows: 1fr; }
.cwd-wl-collage img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cwd-wl-folder-badge {
	position: absolute; left: 0.5rem; bottom: 0.5rem;
	padding: 0.2rem 0.55rem; border-radius: 999px;
	background: rgba(6, 6, 10, 0.85); color: #fff;
	font-size: 0.75rem; font-weight: 500; line-height: 1.4;
}
.cwd-wl-back { display: inline-block; font-size: 0.875rem; color: var(--primary); text-decoration: none; }
.cwd-wl-back:hover, .cwd-wl-back:focus-visible { text-decoration: underline; }

/* ScreenStack's nav ships hidden until sign-in is confirmed; app.css gives
   .ss-nav a display value that would otherwise beat the hidden attribute. */
.ss-nav[hidden] { display: none !important; }

/* --------------------------------------------------------------------- */
/* Sign in / sign out                                                     */
/* --------------------------------------------------------------------- */

/* The only way in used to be a grey "Sign in" after the copyright line in the
   footer, which is not findable. This is the same link as a real control, in
   the primary nav on every page and in its own bar on ScreenStack, where the
   app's own nav is hidden from a signed-out visitor. */
.cwd-auth { display: inline-flex; align-items: center; }
.cwd-auth-btn {
  display: inline-block;
  padding: 5px 14px;
  border: 1px solid var(--border, rgba(255, 255, 255, 0.14));
  border-radius: 999px;
  font-size: 0.8rem;
  line-height: 1.4;
  letter-spacing: -0.01em;
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}
.cwd-auth-btn:hover {
  border-color: var(--color-primary, #e8b86d);
  color: var(--color-primary, #e8b86d);
  background: rgba(232, 184, 109, 0.08);
}
.cwd-auth-btn[hidden] { display: none; }

/* ScreenStack's own header only exists for a signed-in visitor, so a
   signed-out one gets this instead: a way home and a way in. */
.cwd-signedout-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  /* width is explicit because the auto side margins that centre this also
     override the parent column's align-items: stretch, which collapsed the
     bar to its content width and stacked both links in the middle. */
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 16px 18px 0;
}
.cwd-home-link {
  font-size: 0.85rem;
  color: var(--muted, #a8a4b8);
  text-decoration: none;
  letter-spacing: -0.01em;
}
.cwd-home-link:hover { color: var(--accent, #e8b86d); }

@media (max-width: 620px) {
  .cwd-signedout-bar { padding: 12px 14px 0; }
}
