:root{
  --bg: #ffffff;
  --panel: #ffffff;
  --white: #ffffff;
  --text: #111111;
  --muted: #6b6b6b;
  --line: #d8d6cf;
  --line-soft: #e7e4dc;
  --rail-w: 104px;
  --panel-w: 920px;
  --maxw: 1120px;
  --contentw: 980px;
  --shadow-soft: 0 10px 30px rgba(0,0,0,0.05);
  --mobile-header-h: 68px;
}

*{
  box-sizing: border-box;
}

button,
input,
select,
textarea{
  font: inherit;
}

html,
body{
  margin: 0;
  padding: 0;
}

body{
  font-family: "Rockwell", serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img{
  display: block;
  max-width: 100%;
}

a{
  color: inherit;
  text-decoration: none;
}

a:focus-visible,
button:focus-visible{
  outline: 2px solid #111;
  outline-offset: 3px;
}

/* ===== SIDEBAR RAIL + PANEL ===== */

.sidebar{
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  display: flex;
  z-index: 1200;
}

/* franja estreta sempre visible */
.sidebar-rail{
  width: var(--rail-w);
  background: var(--panel);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

/* hamburguesa */
.menu-toggle,
.mobile-menu-toggle{
  appearance: none;
  border: 0;
  background: transparent;
  color: transparent;
  font-size: 0;
  line-height: 0;
  padding: 0;
  cursor: pointer;
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
}

.menu-toggle::before,
.menu-toggle::after,
.mobile-menu-toggle::before,
.mobile-menu-toggle::after{
  content: "";
  position: absolute;
  left: 50%;
  width: 24px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transform: translateX(-50%);
}

.menu-toggle::before,
.mobile-menu-toggle::before{
  top: 14px;
  box-shadow: 0 8px 0 var(--text);
}

.menu-toggle::after,
.mobile-menu-toggle::after{
  top: 30px;
}

.menu-toggle{
  margin-top: 32px;
}

/* logo centrat a la rail */
.rail-logo{
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
}

.rail-logo img{
  width: auto;
  height: 50px;
}

/* panell desplegable */
.sidebar-panel{
  width: 0;
  overflow: hidden;
  background: var(--panel);
  transition: width .28s ease;
  border-right: 1px solid transparent;
  display: flex;
  flex-direction: column;
}

.sidebar.is-open .sidebar-panel{
  width: min(var(--panel-w), calc(100vw - var(--rail-w)));
  border-right-color: var(--line);
}

/* navegació */
.sidebar-nav{
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}

.sidebar-nav a{
  padding: 22px;
  border-bottom: 1px solid var(--line);
  font-size: 1.1rem;
  line-height: 1.2;
  white-space: nowrap;
}

.sidebar-nav a:hover,
.sidebar-nav a[aria-current="page"]{
  background: rgba(255,255,255,0.28);
}

/* footer del panell */
.sidebar-footer{
  margin-top: auto;
  padding: 34px 22px 28px;
  text-align: center;
  color: var(--muted);
}

.sidebar-claim{
  margin: 0;
  font-size: 1rem;
  line-height: 1.5;
  display: inline-block;
}

/* ===== MAIN LAYOUT ===== */

.site-main{
  margin-left: var(--rail-w);
  min-height: 100vh;
  padding: 38px 42px 64px;
}

.home{
  max-width: var(--maxw);
}

/* ===== HERO ===== */

.hero{
  text-align: center;
  padding: 24px 0 34px;
  border-bottom: 1px solid var(--line);
}

.hero-logo-wrap{
  display: flex;
  justify-content: center;
  margin-bottom: 20px;
}

.hero-logo-text{
  width: 420px;
  max-width: 80%;
  height: auto;
}

.hero-claim{
  margin: 0;
  font-size: clamp(1.65rem, 2.7vw, 2.45rem);
  line-height: 1.15;
  font-weight: 400;
}

.hero-social{
  margin-top: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.98rem;
}

.hero-social a:hover{
  color: var(--text);
}

/* ===== HOME FEATURED ===== */

.home-featured{
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 56px;
  padding-top: 46px;
}

.featured-book{
  display: block;
}

.featured-letter{
  display: block;
  padding-top: 4px;
}

.featured-cover{
  display: block;
}

.featured-cover img{
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  box-shadow: var(--shadow-soft);
  transition: transform 0.22s ease, box-shadow 0.22s ease;
}

.featured-cover:hover img{
  transform: translateY(-3px);
  box-shadow: 0 16px 36px rgba(0,0,0,0.08);
}

.eyebrow{
  margin: 0 0 10px;
  font-size: 0.82rem;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.featured-content h2{
  margin: 0 0 14px;
  font-size: clamp(1.5rem, 2.2vw, 2rem);
  line-height: 1.15;
  font-weight: 400;
}

.featured-text{
  margin: 0 0 16px;
  max-width: 44ch;
  font-size: 1.04rem;
  color: #222;
}

.text-link{
  display: inline-block;
  padding-bottom: 2px;
  border-bottom: 1px solid var(--text);
  transition: opacity 0.18s ease;
}

.text-link:hover{
  opacity: 0.7;
}

/* ===== SHARED PAGE STYLES ===== */

.pagina-lletres,
.pagina-llibres,
.contenidor-principal{
  max-width: var(--contentw);
  padding: 6px 0 10px;
}

.pagina-lletres h1,
.pagina-llibres h1,
.contenidor-principal h1{
  text-align: center;
  margin: 10px 0 22px;
  font-size: clamp(2rem, 3vw, 2.7rem);
  line-height: 1.1;
  font-weight: 400;
}

.pagina-lletres h1::after,
.pagina-llibres h1::after,
.contenidor-principal h1::after{
  content: "";
  display: block;
  width: 180px;
  height: 1px;
  background: var(--line);
  margin: 16px auto 0;
}

.contingut-text{
  max-width: 860px;
  margin: 0 auto;
}

.featured-content,
.contingut-text,
.contenidor-principal,
.text-llibre{
  text-align: justify;
  text-justify: inter-word;
}

.featured-content :is(h1, h2, h3, h4, h5, h6),
.contingut-text :is(h1, h2, h3, h4, h5, h6),
.contenidor-principal :is(h2, h3, h4, h5, h6),
.text-llibre :is(h1, h2, h3, h4, h5, h6),
.featured-content :is(button, .button, .btn),
.contingut-text :is(button, .button, .btn),
.contenidor-principal :is(button, .button, .btn),
.text-llibre :is(button, .button, .btn){
  text-align: revert;
}

.featured-content p,
.contingut-text p,
.contenidor-principal p,
.text-llibre p{
  font-size: 1.08rem;
  hyphens: auto;
  -webkit-hyphens: auto;
  overflow-wrap: break-word;
}

.contingut-text p,
.contenidor-principal p{
  margin: 0 0 18px;
}

.paragraf-final{
  color: var(--muted);
  font-size: 0.95rem;
}

.page-intro{
  margin-bottom: 74px;
}

.page-intro p{
  margin: 0;
  font-family: "Rockwell", serif;
  font-size: 1.2rem;
  line-height: 1.95;
  max-width: 58ch;
}

.page-intro::after{
  content: "";
  display: block;
  width: min(100%, 1120px);
  height: 1px;
  background: var(--line);
  margin: 54px auto 0;
}

.articles-state{
  margin: 0 auto 28px;
  max-width: 780px;
  color: var(--muted);
  text-align: center;
}

/* ===== LLETRES ===== */

.llista-articles{
  list-style:none;
  margin:0 auto;
  padding:10px 0 0;
  display:flex;
  flex-direction:column;
  max-width:780px;
}

.llista-articles li{
  text-align:left;
  border-top:1px solid var(--line);
  padding:22px 0;
}

.llista-articles li:first-child{
  border-top:none;
  padding-top:0;
}

.llista-articles a{
  display:grid;
  grid-template-columns:160px 1fr;
  gap:30px;
  align-items:center;
  transition:transform .2s ease;
}

.llista-articles a:hover{
  transform:translateY(-2px);
}

.miniatura{
  width:160px;
  max-width:160px;
  margin:0;
  filter:drop-shadow(0 6px 14px rgba(0,0,0,0.04));
}

.info-lletra{
  display:flex;
  flex-direction:column;
  justify-content:center;
}

.info-lletra p{
  margin:0;
  line-height:1.15;
}

.info-lletra p:first-child{
  font-size:1.35rem;
  font-weight:600;
  margin-bottom:6px;
}

.info-lletra p:last-child{
  font-size:2rem;
  font-weight:400;
}

.llista-articles-dinamica .lletra-card{
  text-align:left;
  padding:42px 0 52px;
}

.llista-articles-dinamica .lletra-card-link{
  display:grid;
  grid-template-columns:240px 1fr;
  gap:24px;
  align-items:center;
}

.info-lletra-order,
.info-lletra-title{
  margin:0;
}

.info-lletra-order{
  font-size:1.05rem;
  line-height:1.2;
  color:var(--text);
  margin-bottom:14px;
  font-weight:600;
}

.info-lletra-title{
  font-size:3rem;
  line-height:1.08;
  margin-bottom:0;
  font-weight:400;
}

/* ===== LLIBRES ===== */

.llistat-llibres{
  display:flex;
  flex-direction:column;
  gap:60px;
  padding-top:20px;
  align-items:center;
}

.llibre{
  display:grid;
  grid-template-columns:260px 1fr;
  gap:36px;
  align-items:center;
  max-width:760px;
  width:100%;
  padding-bottom:36px;
  border-bottom:1px solid var(--line);
}

.llibre:last-child{
  border-bottom:none;
}

.llibre img{
  width:100%;
  background:#fff;
  border:1px solid var(--line);
  box-shadow:var(--shadow-soft);
  transition:transform .22s ease, box-shadow .22s ease;
}

.llibre img:hover{
  transform:translateY(-4px);
  box-shadow:0 16px 36px rgba(0,0,0,0.08);
}

.text-llibre{
  max-width:46ch;
  margin:0 auto;
}

.text-llibre p{
  margin:0 0 16px;
  font-size:1.1rem;
}

.properament{
  margin-top:14px;
  display:inline-block;
  padding:10px 18px;
  font-size:.95rem;
  letter-spacing:.08em;
  text-transform:uppercase;
  font-weight:600;
  border:1px solid var(--line);
  color:var(--muted);
}

.contact-links{
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.contact-link-icon{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 54px;
  height: 54px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  background: #fff;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, opacity 0.18s ease;
}

.contact-link-icon:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  border-color: #bdb8ad;
  opacity: 0.95;
}

.contact-link-icon svg{
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* ===== ARTICLE PAGES ===== */

.contenidor-principal{
  max-width: 800px;
}

.article-pager{
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin: 0 0 18px;
}

.article-pager-link{
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 46px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--text);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.article-pager-link:hover{
  transform: translateY(-2px);
  box-shadow: var(--shadow-soft);
  border-color: #bdb8ad;
}

.article-pager-link.is-next{
  margin-left: auto;
}

.article-pager-arrow{
  font-size: 1.25rem;
  line-height: 1;
}

.article-pager-label{
  font-size: 0.95rem;
  line-height: 1;
}

.article-detail-image{
  display:block;
  width:100%;
  max-width:620px;
  margin:0 auto 18px;
  border:1px solid var(--line);
  background:#fff;
  box-shadow:var(--shadow-soft);
}

.article-detail-meta{
  margin:0 0 18px;
  text-align:center;
  color:var(--muted);
  font-size:0.95rem;
}

.article-draft-badge{
  width:max-content;
  margin:0 auto 18px;
  padding:8px 14px;
  border:1px solid var(--line);
  color:var(--muted);
  font-size:0.9rem;
  letter-spacing:0.06em;
  text-transform:uppercase;
}

.article-detail-excerpt{
  max-width:760px;
  margin:0 auto 22px;
  font-size:1.08rem;
  color:#222;
}

.article-detail-content{
  max-width:860px;
  margin:0 auto;
  text-align:justify;
  text-justify:inter-word;
}

.article-detail-content p{
  margin:0 0 18px;
  font-size:1.08rem;
  hyphens:auto;
  -webkit-hyphens:auto;
  overflow-wrap:break-word;
}

.article-empty{
  max-width:680px;
  margin:0 auto;
  text-align:center;
}

.article-empty p{
  margin:0 0 18px;
}

/* ===== ADMIN ===== */

.admin-page{
  max-width:none;
}

.admin-form{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.admin-field{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.admin-field input,
.admin-field textarea{
  width:100%;
  padding:12px 14px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  line-height:1.5;
}

.admin-field textarea{
  min-height:120px;
  resize:vertical;
}

.admin-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.admin-actions .properament{
  background:#fff;
  cursor:pointer;
}

.admin-note,
.admin-message{
  color:var(--muted);
}

.admin-toolbar{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:20px;
  margin-bottom:28px;
}

.admin-toolbar h1{
  margin-bottom:8px;
}

.admin-toolbar-actions{
  display:flex;
  gap:12px;
  flex-wrap:wrap;
}

.admin-shell{
  display:grid;
  grid-template-columns:minmax(220px, 280px) minmax(0, 520px) minmax(0, 1fr);
  gap:28px;
  align-items:start;
}

.admin-sidebar,
.admin-editor-panel,
.admin-preview-shell{
  min-width:0;
}

.admin-sidebar{
  padding:18px;
  border:1px solid var(--line);
  background:#fbfaf7;
}

.admin-sidebar h2,
.admin-preview-shell h2{
  margin-top:0;
}

.admin-articles-menu{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.admin-article-item{
  width:100%;
  padding:12px 14px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  text-align:left;
  cursor:pointer;
}

.admin-article-item span{
  display:block;
  margin-top:6px;
  color:var(--muted);
  font-size:0.92rem;
}

.admin-article-item.is-active{
  border-color:#111;
}

.admin-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:16px;
}

.admin-checkbox{
  justify-content:flex-end;
}

.admin-toggle{
  display:flex;
  align-items:center;
  gap:10px;
  min-height:48px;
  padding:12px 14px;
  border:1px solid var(--line);
  background:#fff;
}

.editor-toolbar{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.editor-toolbar button{
  min-width:44px;
  padding:10px 12px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  cursor:pointer;
}

.editor-surface{
  min-height:360px;
  padding:16px;
  border:1px solid var(--line);
  background:#fff;
  line-height:1.65;
}

.editor-surface:focus{
  outline:none;
  border-color:#111;
}

.editor-surface p,
.editor-surface h2,
.editor-surface h3,
.editor-surface ul,
.editor-surface ol,
.editor-surface blockquote{
  margin-top:0;
}

.editor-surface h2{
  font-size:1.65rem;
  line-height:1.2;
}

.editor-surface h3{
  font-size:1.35rem;
  line-height:1.25;
}

.admin-preview{
  padding:18px;
  border:1px solid var(--line);
  background:#fbfaf7;
}

.admin-preview-card{
  padding-top:0;
}

/* ===== LOGIN ===== */

.login-page{
  min-height:100vh;
  display:grid;
  place-items:center;
  padding:32px 18px;
}

.login-card{
  width:min(460px, 100%);
  padding:28px;
  border:1px solid var(--line);
  background:#fbfaf7;
}

.login-card h1{
  margin:0 0 12px;
  text-align:left;
}

blockquote{
  margin: 20px 0;
  padding: 0 0 0 18px;
  border-left: 2px solid var(--line);
  color: #333;
  font-style: italic;
}

/* ===== FOOTER ===== */

.site-footer,
footer{
  margin-left: var(--rail-w);
  border-top: 1px solid var(--line);
  background: transparent;
}

.footer-inner,
footer{
  max-width: var(--maxw);
  padding: 18px 42px 24px;
}

.footer-inner p,
footer p{
  margin: 4px 0;
  color: var(--text);
}

.footer-inner a,
footer a{
  text-decoration: underline;
}

/* ===== MOBILE HEADER FIXE ===== */

.mobile-header{
  display: none;
}

/* ===== RESPONSIVE ===== */

@media (max-width: 980px){
  .home-featured{
    grid-template-columns: 1fr;
    gap: 40px;
  }

  .featured-book,
  .llibre{
    grid-template-columns: 220px 1fr;
  }
}

@media (max-width: 900px){
  .sidebar{
    display: none;
  }

  .site-main,
  footer,
  .site-footer{
    margin-left: 0 !important;
  }

  .site-main{
    width: 100%;
    max-width: 100%;
    padding: calc(var(--mobile-header-h) + 18px) 18px 48px;
  }

  .home,
  .pagina-lletres,
  .pagina-llibres,
  .contenidor-principal{
    width: 100%;
    max-width: 100%;
    margin: 0;
  }

  .footer-inner,
  footer{
    padding: 18px 18px 24px;
    text-align: center;
  }

  .mobile-header{
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1300;
    background: #fff;
    border-bottom: 1px solid var(--line);
  }

  .mobile-header-bar{
    height: var(--mobile-header-h);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    padding: 0 16px;
    position: relative;
  }

  .mobile-menu-toggle{
    z-index: 2;
  }

  .mobile-brand{
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-brand span{
    display:none;
  }

  .mobile-logo{
    display: block;
    height: 42px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
  }

  .mobile-nav{
    display: none;
    flex-direction: column;
    justify-content: flex-start;
    position: fixed;
    top: var(--mobile-header-h);
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    min-height: calc(100dvh - var(--mobile-header-h));
    padding: 0;
    padding-bottom: 96px;
    border-top: 1px solid var(--line);
    background: #fff;
    overflow-y: auto;
  }

  .mobile-header.is-open .mobile-nav{
    display: flex;
  }

  .mobile-nav a{
    display: block;
    width: 100%;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    font-size: 1.05rem;
  }

  .mobile-nav a:hover,
  .mobile-nav a[aria-current="page"]{
    background: #f7f7f7;
    border-bottom-color: var(--line);
  }

  .mobile-nav-footer{
    margin-top: auto;
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 28px 18px 34px;
    border-top: 1px solid var(--line);
    text-align: center;
    background: #fff;
    z-index: 1;
  }

  .mobile-nav-claim{
    margin: 0;
    color: #4b4b4b;
    font-size: 1rem;
    line-height: 1.5;
    display: inline-block;
  }

  .hero{
    width: 100%;
    max-width: 100%;
    padding: 10px 0 28px;
  }

  .article-pager{
    margin-bottom: 16px;
  }

  .hero-logo-text{
    width: min(320px, 88vw);
    max-width: 88vw;
    margin: 0 auto;
  }

  .llibre{
    grid-template-columns: 1fr;
    text-align:center;
    gap:20px;
  }

  .llibre img{
    max-width:240px;
    margin:0 auto;
  }

  .text-llibre{
    max-width:none;
  }

  .text-llibre .properament{
    display:block;
    width:100%;
    text-align:center;
  }

  .contact-links{
    justify-content: flex-start;
  }

  .admin-shell{
    grid-template-columns:1fr;
  }

  .admin-toolbar{
    flex-direction:column;
  }

  .admin-grid{
    grid-template-columns:1fr;
  }
}

@media (max-width:700px){
  .llista-articles{
    max-width:420px;
  }

  .llista-articles a{
    grid-template-columns:1fr;
    text-align:center;
  }

  .llista-articles-dinamica .lletra-card-link{
    grid-template-columns:1fr;
    text-align:center;
    gap:6px;
  }

  .llista-articles-dinamica .lletra-card{
    padding:18px 0 22px;
  }

  .page-intro p{
    max-width: none;
    font-size: 1.08rem;
    line-height: 1.8;
  }

  .miniatura{
    margin:0 auto 6px;
    width:140px;
    max-width:140px;
  }

  .info-lletra{
    align-items:center;
  }

  .info-lletra-title{
    font-size:2.4rem;
  }

  .editor-surface{
    min-height:280px;
  }
}

@media (max-width: 560px){
  .hero{
    padding-top: 10px;
  }

  .article-pager{
    gap: 10px;
  }

  .article-pager-link{
    padding: 10px 14px;
  }

  .article-pager-label{
    display: none;
  }

  .hero-claim{
    font-size: 1.95rem;
  }

  .pagina-lletres h1,
  .pagina-llibres h1,
  .contenidor-principal h1{
    font-size: 2.2rem;
  }
}
