/*
Theme Name: Sakku Chapters Book
Theme URI: https://sakkuchapters.com/
Author: Sakku Chapters
Description: A book-style theme for a short-story author. Author introduction and picture on the home page, a contents list of all stories, and Home / Previous / Next navigation with the author's picture and name on every story. Includes Light, Sepia and Dark reading modes, text size controls, focus mode and an email subscription for new stories.
Version: 1.0.0
Requires at least: 6.0
Requires PHP: 7.4
License: GPL-2.0-or-later
Text Domain: sakku-book
*/

:root {
	--paper: #F4F6F1;
	--paper-2: #E8EDE3;
	--card: #FFFFFF;
	--ink: #17232C;
	--muted: #566871;
	--accent: #0E6A67;
	--accent-ink: #FFFFFF;
	--mango: #F0B323;
	--line: #CBD3C6;
	--fs: 1.2rem;
	--display: 'Fraunces', 'Noto Serif Malayalam', Georgia, serif;
	--serif: 'Noto Serif Malayalam', Georgia, serif;
	--sans: 'Noto Sans Malayalam', system-ui, -apple-system, 'Segoe UI', sans-serif;
	--radius: 10px;
}
html[data-theme="sepia"] {
	--paper: #F1E5CB;
	--paper-2: #E6D6B4;
	--card: #F7EEDA;
	--ink: #3A2C18;
	--muted: #78654A;
	--accent: #7A4B1C;
	--accent-ink: #FFF8EA;
	--line: #CDB98F;
}
html[data-theme="dark"] {
	--paper: #0F161B;
	--paper-2: #18232B;
	--card: #141D23;
	--ink: #E3E8E4;
	--muted: #95A5AD;
	--accent: #5CC4BC;
	--accent-ink: #08201F;
	--line: #2A3A44;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
	margin: 0;
	background: var(--paper);
	color: var(--ink);
	font-family: var(--sans);
	font-size: 1rem;
	line-height: 1.7;
	padding-bottom: 5.5rem;
	transition: background-color .2s, color .2s;
}
img { max-width: 100%; height: auto; display: block; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--mango); outline-offset: 2px; border-radius: 4px; }
.screen-reader-text, .skip-link:not(:focus) {
	position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 999; background: var(--card); padding: .6rem 1rem; }

.wrap { width: min(1080px, 100% - 2.5rem); margin-inline: auto; }
.narrow { width: min(760px, 100% - 2.5rem); margin-inline: auto; }
.reading { width: min(720px, 100% - 2.5rem); margin-inline: auto; }

/* Progress */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; background: var(--mango); z-index: 60; }

/* Header */
.site-header {
	position: sticky; top: 0; z-index: 50;
	background: color-mix(in srgb, var(--paper) 92%, transparent);
	backdrop-filter: blur(8px);
	border-bottom: 1px solid var(--line);
}
.bar { display: flex; align-items: center; gap: 1rem; min-height: 68px; }
.brand { display: flex; align-items: center; gap: .75rem; text-decoration: none; color: var(--ink); margin-right: auto; min-width: 0; }
.brand-name { font-family: var(--display); font-weight: 600; font-size: 1.15rem; line-height: 1.2; }
.scb-avatar { border-radius: 50%; object-fit: cover; background: var(--paper-2); aspect-ratio: 1; flex: none; }
.brand-photo { width: 44px; height: 44px; border: 2px solid var(--mango); }
.scb-initial { display: inline-grid; place-items: center; font-family: var(--display); font-weight: 800; background: var(--accent); color: var(--accent-ink); }
.main-nav .menu { display: flex; gap: 1.4rem; list-style: none; margin: 0; padding: 0; }
.main-nav a { color: var(--ink); text-decoration: none; font-weight: 500; padding: .3rem 0; border-bottom: 2px solid transparent; }
.main-nav a:hover, .main-nav .current-menu-item a { border-bottom-color: var(--mango); }
.btn-ghost, .nav-toggle {
	font: inherit; font-weight: 500; font-size: .95rem; color: var(--ink); background: transparent;
	border: 1px solid var(--line); border-radius: 999px; padding: .4rem 1rem; cursor: pointer;
}
.btn-ghost:hover, .nav-toggle:hover { border-color: var(--accent); color: var(--accent); }
.nav-toggle { display: none; }

/* Buttons */
.btn {
	display: inline-block; font-family: var(--sans); font-weight: 600; text-decoration: none;
	background: var(--accent); color: var(--accent-ink); padding: .8rem 1.5rem; border-radius: 999px; border: 2px solid var(--accent);
}
.btn:hover { filter: brightness(1.1); }
.btn-quiet { background: transparent; color: var(--accent); }

/* Hero (home + author page) */
.hero { padding: clamp(2.5rem, 7vw, 5.5rem) 0 clamp(2rem, 5vw, 4rem); }
.hero-grid { display: grid; grid-template-columns: minmax(240px, 5fr) 7fr; gap: clamp(2rem, 6vw, 5rem); align-items: center; }
.portrait-wrap { position: relative; width: min(100%, 380px); margin-inline: auto; }
.portrait-wrap::before {
	content: ""; position: absolute; inset: 20px -20px -20px 20px; background: var(--mango);
	border-radius: 999px 999px 14px 14px;
}
.portrait {
	position: relative; aspect-ratio: 4 / 5; overflow: hidden; background: var(--paper-2);
	border-radius: 999px 999px 14px 14px; border: 3px solid var(--ink);
}
.portrait .scb-avatar { width: 100%; height: 100%; border-radius: 0; aspect-ratio: auto; }
.portrait .scb-initial { font-size: 7rem; }
.hero-name { font-family: var(--display); font-weight: 800; font-size: clamp(2.2rem, 5.2vw, 3.9rem); line-height: 1.08; margin: 0 0 .6rem; letter-spacing: -.01em; }
.hero-tag { font-family: var(--serif); font-size: 1.2rem; color: var(--accent); margin: 0 0 1.2rem; }
.hero-bio { font-family: var(--serif); font-size: 1.1rem; line-height: 1.95; max-width: 60ch; }
.hero-bio p { margin: 0 0 1em; }
.hero-actions { display: flex; flex-wrap: wrap; gap: .8rem; margin: 1.6rem 0 1.2rem; }
.social { display: flex; flex-wrap: wrap; gap: .4rem 1.2rem; list-style: none; padding: 0; margin: .5rem 0 0; font-size: .95rem; }
.hero-page { padding-bottom: 2rem; }

/* Contents list */
.toc-section { padding: 1rem 0 4rem; }
.section-title { font-family: var(--display); font-weight: 800; font-size: clamp(1.8rem, 4vw, 2.4rem); margin: 0 0 1.5rem; padding-bottom: .7rem; border-bottom: 3px solid var(--ink); }
.lede { color: var(--muted); margin-top: -.6rem; }
.year { font-family: var(--display); font-size: 1.3rem; margin: 2.2rem 0 .4rem; color: var(--accent); }
.toc { list-style: none; margin: 0; padding: 0; }
.toc-item { padding: 1.1rem 0; border-bottom: 1px solid var(--line); }
.toc-link { display: flex; align-items: baseline; gap: .6rem; text-decoration: none; color: var(--ink); }
.toc-title { font-family: var(--serif); font-weight: 700; font-size: 1.2rem; line-height: 1.5; }
.toc-leader { flex: 1; min-width: 1.5rem; border-bottom: 2px dotted var(--line); transform: translateY(-.35em); }
.toc-date { font-size: .88rem; color: var(--muted); white-space: nowrap; }
.toc-link:hover .toc-title { color: var(--accent); text-decoration: underline; text-decoration-color: var(--mango); text-decoration-thickness: 3px; text-underline-offset: 4px; }
.toc-excerpt { margin: .3rem 0 0; color: var(--muted); font-family: var(--serif); font-size: .98rem; line-height: 1.8; }
.toc-compact .toc-item { padding: .6rem 0; }
.pagination { margin-top: 2rem; }
.pagination .page-numbers { display: inline-block; padding: .4rem .9rem; margin: 0 .2rem .4rem 0; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--ink); }
.pagination .current { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

/* Story page */
.story { padding: 1.5rem 0 3rem; }
.story-top { display: flex; justify-content: space-between; gap: 1rem; font-size: .95rem; margin-bottom: 2rem; }
.story-top a { text-decoration: none; font-weight: 600; }
.story-top-pn { display: flex; gap: 1.2rem; }
.story-title { font-family: var(--serif); font-weight: 700; font-size: clamp(1.9rem, 5vw, 2.8rem); line-height: 1.35; margin: 0 0 1.2rem; }
.story-head { padding-bottom: 1.4rem; margin-bottom: 1.8rem; border-bottom: 1px solid var(--line); position: relative; }
.story-head::after { content: ""; position: absolute; left: 0; bottom: -3px; width: 72px; height: 5px; background: var(--mango); }
.byline { display: flex; align-items: center; gap: .9rem; }
.byline-photo { width: 52px; height: 52px; border: 2px solid var(--mango); }
.byline-text { display: flex; flex-direction: column; line-height: 1.4; }
.byline-text span { font-size: .88rem; color: var(--muted); }
.story-image { margin: 0 0 2rem; }
.story-image img { border-radius: var(--radius); }
.story-body { font-family: var(--serif); font-size: var(--fs); line-height: 2.05; overflow-wrap: break-word; }
.story-body p { margin: 0 0 1.25em; }
.story-body h2, .story-body h3 { font-family: var(--serif); line-height: 1.5; margin: 2em 0 .6em; }
.story-body blockquote { margin: 1.5em 0; padding: .2em 0 .2em 1.2em; border-left: 4px solid var(--mango); color: var(--muted); }
.story-body img { border-radius: var(--radius); margin-inline: auto; }
.story-body figure { margin: 1.5em 0; }
.story-body figcaption { font-size: .85rem; color: var(--muted); text-align: center; }

.author-card { display: flex; gap: 1.2rem; align-items: center; margin: 3rem 0 1.5rem; padding: 1.3rem; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.card-photo { width: 88px; height: 88px; border: 3px solid var(--mango); }
.author-card h2 { font-family: var(--display); font-size: 1.25rem; margin: 0 0 .2rem; }
.author-card p { margin: 0; color: var(--muted); font-family: var(--serif); font-size: .95rem; line-height: 1.8; }

.story-nav { display: grid; grid-template-columns: 1fr auto 1fr; gap: .8rem; margin: 1.5rem 0 2rem; }
.sn { display: flex; flex-direction: column; gap: .15rem; padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); background: var(--card); min-width: 0; }
.sn small { color: var(--muted); font-size: .8rem; }
.sn span { font-family: var(--serif); font-weight: 700; line-height: 1.5; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.sn:hover { border-color: var(--accent); }
.sn-next { text-align: right; }
.sn-home { text-align: center; justify-content: center; background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.sn-home small { color: inherit; opacity: .85; }
.sn-empty { border: 0; background: none; }

/* Comments */
.comments { margin-top: 2.5rem; }
.comments-title, .comment-reply-title { font-family: var(--display); font-size: 1.3rem; }
.comment-list { padding-left: 1.2rem; }
.comment-list li { margin-bottom: 1.2rem; }
.comment-form input[type=text], .comment-form input[type=email], .comment-form input[type=url], .comment-form textarea, .search-field {
	width: 100%; font: inherit; padding: .65rem .8rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--card); color: var(--ink);
}
.comment-form input[type=submit], .search-submit { font: inherit; font-weight: 600; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: .7rem 1.5rem; cursor: pointer; }

/* Subscribe */
.subscribe { background: var(--ink); color: var(--paper); padding: 3rem 0; margin-top: 2rem; }
.subscribe h2 { font-family: var(--display); margin: 0 0 .3rem; font-size: 1.7rem; }
.subscribe p { margin: 0 0 1.2rem; opacity: .85; }
.sub-form { display: flex; gap: .6rem; flex-wrap: wrap; position: relative; }
.sub-form input[type=email] { flex: 1 1 240px; font: inherit; padding: .8rem 1.1rem; border-radius: 999px; border: 2px solid transparent; background: #fff; color: #17232C; }
.sub-form button { font: inherit; font-weight: 700; padding: .8rem 1.7rem; border-radius: 999px; border: 0; background: var(--mango); color: #17232C; cursor: pointer; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }
.sub-note { margin-top: .9rem; font-weight: 600; }
.sub-ok { color: var(--mango); }
.sub-invalid, .sub-error { color: #FFB4A8; }

/* Footer */
.site-footer { padding: 2.5rem 0 1rem; border-top: 1px solid var(--line); }
.foot { display: grid; gap: 1.2rem; }
.foot-author { display: flex; align-items: center; gap: 1rem; }
.foot-author .scb-avatar { width: 56px; height: 56px; border: 2px solid var(--mango); }
.foot-author .social { margin: .2rem 0 0; }
.foot-nav ul { display: flex; gap: 1.2rem; list-style: none; padding: 0; margin: 0; }
.copy { color: var(--muted); font-size: .88rem; margin: 0; }

/* Contents drawer */
.drawer-overlay { position: fixed; inset: 0; background: rgba(10, 20, 26, .5); opacity: 0; visibility: hidden; transition: opacity .2s, visibility .2s; z-index: 70; }
.drawer {
	position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 92vw); z-index: 80;
	background: var(--paper); border-left: 1px solid var(--line); display: flex; flex-direction: column;
	transform: translateX(100%); visibility: hidden; transition: transform .25s ease, visibility .25s;
}
body.drawer-open .drawer { transform: none; visibility: visible; }
body.drawer-open .drawer-overlay { opacity: 1; visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-family: var(--display); font-size: 1.3rem; }
.drawer-home { margin: .8rem 1.2rem 0; font-weight: 600; }
.drawer-body { overflow-y: auto; padding: .4rem 1.2rem 2rem; }
.drawer-body h3 { font-family: var(--display); color: var(--accent); margin: 1.2rem 0 .3rem; }
.drawer-body ol { list-style: none; margin: 0; padding: 0; }
.drawer-body li a { display: block; padding: .45rem .6rem; font-family: var(--serif); color: var(--ink); text-decoration: none; border-radius: 6px; line-height: 1.5; }
.drawer-body li a:hover { background: var(--paper-2); }
.drawer-body li a.is-current { background: var(--mango); color: #17232C; font-weight: 700; }

/* Reading bar */
.readbar {
	position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); z-index: 55;
	display: flex; align-items: center; gap: .5rem; padding: .35rem; max-width: calc(100vw - 16px);
	background: var(--card); border: 1px solid var(--line); border-radius: 999px; box-shadow: 0 6px 24px rgba(0, 0, 0, .14);
}
.seg { display: flex; border-right: 1px solid var(--line); padding-right: .5rem; }
.readbar button { font: inherit; font-size: .88rem; font-weight: 500; color: var(--ink); background: transparent; border: 0; border-radius: 999px; padding: .4rem .8rem; cursor: pointer; white-space: nowrap; }
.readbar button:hover { background: var(--paper-2); }
.readbar button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); }
.seg-single { margin-right: .2rem; }

/* Focus mode: only the story and the reading bar remain */
body.focus-mode .site-header, body.focus-mode .site-footer, body.focus-mode .subscribe,
body.focus-mode .story-top, body.focus-mode .author-card, body.focus-mode .comments { display: none; }

/* Responsive */
@media (max-width: 820px) {
	.hero-grid { grid-template-columns: 1fr; text-align: left; }
	.portrait-wrap { width: min(70%, 300px); margin: 0 auto 1.5rem 20px; }
	.nav-toggle { display: inline-block; }
	.main-nav { display: none; position: absolute; top: 100%; left: 0; right: 0; background: var(--paper); border-bottom: 1px solid var(--line); padding: 1rem 1.25rem; }
	.main-nav.open { display: block; }
	.main-nav .menu { flex-direction: column; gap: .6rem; }
	.brand-name { font-size: 1rem; }
	.toc-leader { display: none; }
	.toc-link { flex-wrap: wrap; justify-content: space-between; }
	.story-nav { grid-template-columns: 1fr 1fr; }
	.sn-home { grid-column: 1 / -1; order: 3; }
	.author-card { flex-direction: column; text-align: center; }
	.readbar { gap: .2rem; }
	.readbar button { padding: .4rem .55rem; font-size: .82rem; }
}
@media (prefers-reduced-motion: reduce) {
	html { scroll-behavior: auto; }
	* { transition: none !important; }
}
