/*
Theme Name: The Shared Measure
Theme URI: https://thesharedmeasure.com
Author: Tayseer Alfalah
Author URI: https://tayseeralfalah.com
Description: A block theme for The Shared Measure — historical romantic suspense from the Ottoman Levant. Every section is editable in Appearance → Editor. Ready for English, Arabic (right-to-left) and further languages via Polylang.
Requires at least: 6.6
Tested up to: 7.1
Requires PHP: 7.4
Version: 1.0.5
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: the-shared-measure
*/

/* ---------- Base ---------- */
:root{
  --sm-walnut:#1D1611; --sm-bark:#2A2019; --sm-parchment:#EBE0C9; --sm-smoke:#B3A68F;
  --sm-brass:#C1924F; --sm-indigo:#24335A; --sm-wax:#8E2A22; --sm-ink:#2B2118;
  --sm-tally-w:min(560px,84vw);
}
body{ -webkit-font-smoothing:antialiased; text-rendering:optimizeLegibility; font-feature-settings:"liga","onum"; }
::selection{ background:var(--sm-brass); color:var(--sm-walnut); }
a:focus-visible,.wp-element-button:focus-visible{ outline:2px solid var(--sm-brass); outline-offset:3px; }

/* ---------- Header ---------- */
.sm-header{ border-bottom:1px solid rgba(193,146,79,.22); }
.sm-header .wp-block-site-title{ font-family:var(--wp--preset--font-family--display); font-size:1.35rem; margin:0; }
.sm-header .wp-block-site-title a{ color:var(--sm-parchment); text-decoration:none; }
.sm-lang{ margin:0; font-size:.95rem; display:flex; gap:1.25rem; }
.sm-lang a{ color:var(--sm-smoke); text-decoration:none; }
.sm-lang a:hover{ color:var(--sm-brass); }
.sm-lang a[lang="ar"]{ font-family:var(--wp--preset--font-family--arabic); font-size:1.1rem; }

/* ---------- Title page (hero) ---------- */
.sm-hero{
  min-height:min(92vh,980px); display:flex; flex-direction:column; justify-content:center;
  text-align:center; position:relative; overflow:hidden;
  background:
    radial-gradient(60rem 40rem at 18% 12%, rgba(193,146,79,.20), transparent 60%),
    radial-gradient(50rem 30rem at 85% 100%, rgba(36,51,90,.45), transparent 70%),
    var(--sm-walnut);
}
.sm-byline{ font-style:italic; color:var(--sm-smoke); font-size:1.05rem; margin-bottom:1.5rem !important; }
.sm-title{
  font-size:clamp(3.1rem, 9.5vw, 7.6rem) !important; line-height:.92 !important; margin:0 auto !important;
  letter-spacing:-.01em; color:var(--sm-parchment); font-weight:400;
}
.sm-tagline{ font-family:var(--wp--preset--font-family--display); font-style:italic; font-size:clamp(1.35rem,2.6vw,1.9rem); color:var(--sm-parchment); margin-top:2.25rem !important; }
.sm-genre{ color:var(--sm-smoke); max-width:34rem; margin-inline:auto !important; }
.sm-hero .wp-block-buttons{ justify-content:center; margin-top:2.25rem; }

/* ---------- The tally (signature element) ---------- */
.wp-block-separator.sm-tally{
  --w:var(--sm-tally-w);
  width:var(--w) !important; max-width:none; height:44px; margin:2.6rem auto 0 !important;
  border:0 !important; background:none !important; opacity:1 !important; position:relative; overflow:visible;
}
.wp-block-separator.sm-tally::before,
.wp-block-separator.sm-tally::after{
  content:""; position:absolute; top:0; height:100%;
  background:
    linear-gradient(90deg, transparent 0 calc(var(--w)*.08), #24160b calc(var(--w)*.08) calc(var(--w)*.13), transparent calc(var(--w)*.13)) 0 0 / var(--w) 62% no-repeat,
    repeating-linear-gradient(90deg, transparent 0 calc(var(--w)*.045), #2a190c calc(var(--w)*.045) calc(var(--w)*.05)) calc(var(--w)*.15) 0 / calc(var(--w)*.62) 40% no-repeat,
    linear-gradient(180deg, #8b6338 0%, #a57a47 38%, #7a5530 70%, #5a3c22 100%);
  box-shadow: 0 14px 30px rgba(0,0,0,.45), inset 0 1px 0 rgba(255,230,190,.25);
  border-radius:3px;
}
/* Stock: the longer half (left) */
.wp-block-separator.sm-tally::before{
  left:0; width:60%;
  clip-path:polygon(0 0,100% 0,96.67% 25%,100% 50%,96.67% 75%,100% 100%,0 100%);
  border-radius:22px 0 0 22px;
  animation:smJoinL 1.5s cubic-bezier(.2,.7,.2,1) .35s both;
}
/* Foil: the shorter half (right) — the same notches continue across the seam */
.wp-block-separator.sm-tally::after{
  left:58%; width:42%;
  background-position: calc(var(--w)*-.58) 0, calc(var(--w)*(.15 - .58)) 0, 0 0;
  clip-path:polygon(4.76% 0,100% 0,100% 100%,4.76% 100%,0 75%,4.76% 50%,0 25%);
  border-radius:0 6px 6px 0;
  animation:smJoinR 1.5s cubic-bezier(.2,.7,.2,1) .35s both;
}
@keyframes smJoinL{ from{ transform:translateX(-26px); } to{ transform:none; } }
@keyframes smJoinR{ from{ transform:translateX(26px); } to{ transform:none; } }
.sm-tally-caption{ font-style:italic; color:var(--sm-smoke); font-size:.95rem; text-align:center; margin-top:1.1rem !important; }

/* ---------- Book One (first page) ---------- */
.sm-book{ background:var(--sm-indigo); }
.sm-book .wp-block-columns{ align-items:center; gap:clamp(2rem,6vw,5rem); }
.sm-book-title{ font-size:clamp(2.4rem,5vw,3.6rem) !important; margin-bottom:.3rem !important; line-height:1.02 !important; }
.sm-book-sub{ font-style:italic; color:var(--sm-brass); margin-top:0 !important; font-size:1.15rem; }
.sm-book .has-drop-cap:not(:focus)::first-letter{ font-family:var(--wp--preset--font-family--display); color:var(--sm-brass); font-size:4.6em; line-height:.8; margin:.08em .12em 0 0; }
.sm-book-place{ font-family:var(--wp--preset--font-family--display); font-style:italic; color:var(--sm-smoke); }
.sm-buy .wp-block-button .wp-block-button__link{ background:transparent; color:var(--sm-parchment); border:1px solid rgba(235,224,201,.35); font-size:.95rem; padding:.55em 1.1em; }
.sm-buy .wp-block-button .wp-block-button__link:hover{ border-color:var(--sm-brass); color:var(--sm-brass); }
.sm-buy-note{ font-size:.9rem; color:var(--sm-smoke); font-style:italic; }

/* ---------- Historical note ---------- */
.sm-note{ text-align:left; }
.sm-fleuron{ text-align:center; color:var(--sm-brass); font-size:1.6rem; margin-bottom:1.6rem !important; }
.sm-note h2,.sm-contents h2,.sm-author h2{ text-align:center; }

/* ---------- Contents (the Galata Cycle) ---------- */
.sm-contents{ background:var(--sm-bark); }
.sm-contents-intro{ text-align:center; color:var(--sm-smoke); max-width:36rem; margin-inline:auto !important; }
ol.sm-toc{ list-style:none; padding:0; margin:2.6rem auto 0; max-width:36rem; counter-reset:sm; }
ol.sm-toc li{ counter-increment:sm; display:flex; align-items:baseline; gap:.9rem; padding:.7rem 0; font-size:1.15rem; }
ol.sm-toc li::before{ content:counter(sm, upper-roman) "."; font-family:var(--wp--preset--font-family--display); color:var(--sm-brass); min-width:2.2rem; }
.sm-toc-t{ flex:1; display:flex; align-items:baseline; font-family:var(--wp--preset--font-family--display); font-size:1.3rem; }
.sm-toc-t::after{ content:""; flex:1; border-bottom:1px dotted rgba(235,224,201,.35); margin:0 .6rem .3rem; }
.sm-toc-s{ font-style:italic; color:var(--sm-smoke); font-size:.95rem; white-space:nowrap; }

/* ---------- About the author ---------- */
.sm-signature{ text-align:center; font-family:var(--wp--preset--font-family--arabic); font-size:2.2rem; color:var(--sm-brass); margin-top:1.4rem !important; line-height:1.2; }
.sm-author p{ text-align:center; }

/* ---------- A letter to the reader (signup) ---------- */
.sm-letter-wrap{ background:var(--sm-walnut); }
.sm-letter{
  background:linear-gradient(180deg,#EFE5CF,#E4D6BA); color:var(--sm-ink); position:relative;
  padding:clamp(2rem,5vw,3.5rem) !important; max-width:40rem; margin-inline:auto;
  box-shadow:0 24px 50px rgba(0,0,0,.45); border-radius:2px;
}
.sm-letter::after{ content:""; position:absolute; width:58px; height:58px; right:-14px; bottom:-14px; border-radius:50%;
  background:radial-gradient(circle at 38% 35%, #b8453a, var(--sm-wax) 55%, #5e1a14); box-shadow:0 6px 14px rgba(0,0,0,.4); }
.sm-letter h2{ color:var(--sm-ink); margin-top:0 !important; }
.sm-letter p{ color:#3d3025; }
.sm-letter .wp-block-button__link{ background:var(--sm-ink); color:var(--sm-parchment); }
.sm-letter .wp-block-button__link:hover{ background:var(--sm-wax); }
.sm-letter-small{ font-size:.9rem; font-style:italic; }

/* ---------- Footer (colophon) ---------- */
.sm-footer{ border-top:1px solid rgba(193,146,79,.22); text-align:center; color:var(--sm-smoke); font-size:.95rem; }
.sm-footer a{ color:var(--sm-smoke); }
.sm-footer a:hover{ color:var(--sm-brass); }
.sm-footer .wp-block-social-links{ justify-content:center; }
.sm-footer .wp-social-link{ color:var(--sm-parchment) !important; }

/* ---------- Arabic & right-to-left ---------- */
.sm-ar, html[dir="rtl"] body{ font-family:var(--wp--preset--font-family--arabic); }
.sm-ar{ direction:rtl; }
.sm-ar h1,.sm-ar h2,.sm-ar h3,.sm-ar .sm-tagline,.sm-ar .sm-toc-t,.sm-ar .sm-jacket-title,.sm-ar .sm-jacket-author,.sm-ar .sm-book-place,
html[dir="rtl"] h1,html[dir="rtl"] h2,html[dir="rtl"] h3{ font-family:var(--wp--preset--font-family--arabic); font-style:normal; }
.sm-ar .sm-title{ font-size:clamp(3rem,9vw,6.8rem) !important; line-height:1.15 !important; font-weight:700; }
.sm-ar .sm-note{ text-align:right; }
.sm-ar p{ line-height:1.95; }
.sm-ar .sm-tally{ direction:ltr; }
.sm-ar ol.sm-toc li::before{ content:counter(sm, arabic-indic) "."; }
.sm-ar .sm-letter::after{ right:auto; left:-14px; }
.sm-ar .sm-latin{ font-family:var(--wp--preset--font-family--display); direction:ltr; unicode-bidi:isolate; }

/* ---------- Chinese (for later) ---------- */
.sm-zh, html[lang^="zh"] body{ font-family:var(--wp--preset--font-family--chinese); }

/* ---------- Accessibility ---------- */
@media (prefers-reduced-motion: reduce){
  .wp-block-separator.sm-tally::before,.wp-block-separator.sm-tally::after{ animation:none; }
}
@media (max-width:781px){
  .sm-book .wp-block-column{ text-align:left; }
  .sm-ar .sm-book .wp-block-column{ text-align:right; }
}

/* ---------- Section rhythm ---------- */
.sm-sec{ padding-top:var(--wp--preset--spacing--70) !important; padding-bottom:var(--wp--preset--spacing--70) !important; }
.sm-hero.sm-sec{ padding-top:var(--wp--preset--spacing--50) !important; }
.sm-header{ padding-top:1.1rem; padding-bottom:1.1rem; }
.sm-footer{ padding-top:var(--wp--preset--spacing--50); padding-bottom:var(--wp--preset--spacing--50); }
.sm-footer p{ margin:.4rem 0; }
.sm-ar .sm-signature{ font-family:var(--wp--preset--font-family--display); font-size:1.8rem; }
.sm-ar .sm-byline,.sm-ar .sm-book-sub,.sm-ar .sm-tally-caption,.sm-ar .sm-buy-note,.sm-ar .sm-toc-s,.sm-ar .sm-letter-small,.sm-ar .sm-jacket-series{ font-style:normal; }
.sm-ar .sm-jacket-title{ font-size:clamp(2.4rem,4vw,3rem) !important; font-weight:700; }
.sm-ar .sm-book-title{ font-weight:700; }

/* ---------- Refinements (v1.0.1) ---------- */
/* a visible hairline seam between stock and foil, and one shadow for the whole stick */
.wp-block-separator.sm-tally{ filter:drop-shadow(0 12px 18px rgba(0,0,0,.5)); }
.wp-block-separator.sm-tally::before,.wp-block-separator.sm-tally::after{ box-shadow:none; }
.wp-block-separator.sm-tally::after{ left:calc(58% + 2px); width:calc(42% - 2px); }

/* ---------- Signature image (v1.0.2) ---------- */
.sm-signature-img{ margin-top:1.6rem !important; }
.sm-signature-img img{ height:auto; opacity:.95; }
.wp-block-image.sm-signature-img{ display:table; margin-left:auto !important; margin-right:auto !important; }

/* ---------- Contents rows (v1.0.3): each book = one editable row ---------- */
.sm-toc{ max-width:36rem; margin:2.6rem auto 0 !important; counter-reset:smbook; }
.sm-toc-row{ counter-increment:smbook; display:flex; align-items:baseline !important; gap:.9rem; padding:.7rem 0; margin:0 !important; }
.sm-toc-row::before{ content:counter(smbook, upper-roman) "."; font-family:var(--wp--preset--font-family--display); color:var(--sm-brass); min-width:2.2rem; font-size:1.15rem; }
.sm-toc-row p{ margin:0 !important; }
.sm-toc-row .sm-toc-t{ flex:1; display:flex; align-items:baseline; font-family:var(--wp--preset--font-family--display); font-size:1.3rem; }
.sm-toc-row .sm-toc-t::after{ content:""; flex:1; border-bottom:1px dotted rgba(235,224,201,.35); margin:0 .6rem .3rem; }
.sm-toc-row .sm-toc-s{ font-style:italic; color:var(--sm-smoke); font-size:.95rem; white-space:nowrap; }
.sm-ar .sm-toc-row::before{ content:counter(smbook, arabic-indic) "."; font-family:var(--wp--preset--font-family--arabic); }
.sm-ar .sm-toc-row .sm-toc-t{ font-family:var(--wp--preset--font-family--arabic); }
.sm-ar .sm-toc-row .sm-toc-s{ font-style:normal; }
@media (max-width:520px){ .sm-toc-row .sm-toc-t::after{ display:none; } .sm-toc-row{ flex-wrap:wrap !important; } }

/* ---------- Book jacket = core Cover block (v1.0.5): every editor control works ---------- */
.wp-block-cover.sm-jacket{ width:min(100%,360px); margin-inline:auto; aspect-ratio:2/3; min-height:0; padding:1.6rem 1.2rem;
  box-shadow:-14px 22px 40px rgba(0,0,0,.55), 0 0 0 1px rgba(193,146,79,.35); border-left:6px solid rgba(0,0,0,.35); }
@media (max-width:781px){ .wp-block-cover.sm-jacket{ width:min(78vw,300px); } }
.sm-jacket .wp-block-cover__inner-container{ width:100%; }
.sm-jacket p{ margin:0 0 .4rem; color:var(--sm-parchment); text-shadow:0 2px 10px rgba(0,0,0,.6); }
.sm-jacket .sm-jacket-series{ font-style:italic; font-size:.9rem; color:var(--sm-brass); }
.sm-jacket .sm-jacket-title{ font-family:var(--wp--preset--font-family--display); font-size:2.3rem; line-height:1.05; }
.sm-jacket .sm-jacket-author{ font-family:var(--wp--preset--font-family--display); font-size:1.15rem; letter-spacing:.04em; }
.sm-ar .sm-jacket .sm-jacket-title,.sm-ar .sm-jacket .sm-jacket-author{ font-family:var(--wp--preset--font-family--arabic); }
.sm-ar .sm-jacket .sm-jacket-title{ font-size:2.8rem; font-weight:700; }
.sm-ar .sm-jacket .sm-jacket-series{ font-style:normal; }

/* ---------- Header logo (v1.0.5) ---------- */
.sm-brand{ gap:.9rem; align-items:center; }
.sm-header .wp-block-site-logo img{ height:auto; }
.sm-brand:has(.wp-block-site-logo img) .wp-block-site-title{ display:none; }
