@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+Tamil:wght@400;500;600&family=Noto+Serif+Tamil:wght@400;600;700&display=swap');

:root {
  --ink: #f2efe9;
  --muted: #a49d92;
  --bg: #161616;
  --surface: #1f1f21;
  --line: #33302c;
  --rust: #c4682a;
  --rust-soft: #e8a26b;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; background: var(--bg); }

body {
  margin: 0;
  font-family: "Noto Sans Tamil", "Noto Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1100px 500px at 80% -10%, rgba(196, 104, 42, 0.16), transparent 60%),
    var(--bg);
  line-height: 1.85;
}

header, nav, main, footer {
  max-width: 1080px;
  margin: 0 auto;
  padding-left: 16px;
  padding-right: 16px;
}

/* profile header */
header { padding-top: 36px; padding-bottom: 22px; }

.profile { display: flex; align-items: center; gap: 20px; }

.avatar {
  flex: none;
  width: 34px; height: 34px;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(from 210deg, #f9ce34, #ee2a7b, #c4682a, #6228d7, #f9ce34);
}

.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }

.avatar.big { width: 76px; height: 76px; padding: 3px; }

h1 {
  font-family: "Noto Serif Tamil", "Noto Serif", Georgia, serif;
  font-weight: 700;
  font-size: clamp(24px, 4.6vw, 34px);
  margin: 0;
  letter-spacing: 0.01em;
}

.sub { color: var(--rust-soft); font-size: 13.5px; margin-top: 2px; }

.counts {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  font-size: 13.5px;
  color: var(--muted);
}

.counts span::first-letter { font-weight: 600; }

/* nav */
nav {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  padding-bottom: 12px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: rgba(22, 22, 22, 0.94);
  backdrop-filter: blur(6px);
  z-index: 5;
}

nav button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13.5px;
}

nav button.active { background: var(--rust); border-color: var(--rust); color: #fff3ea; }

nav label { margin-left: auto; }

#search {
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 999px;
  padding: 7px 14px;
  font-family: inherit;
  font-size: 13.5px;
  outline: none;
}

#search::placeholder { color: var(--muted); }

.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* feed */
.grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 22px;
}

#empty { color: var(--muted); padding: 40px 0; text-align: center; }

/* post card */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  scroll-margin-top: 70px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-bottom: 1px solid var(--line);
}

.handle { font-size: 14px; font-weight: 600; color: var(--ink); }

.badge {
  padding: 1px 8px;
  border: 1px solid var(--rust-soft);
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--rust-soft);
}

.pnum { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.ta {
  font-family: "Noto Serif Tamil", "Noto Serif", Georgia, serif;
  font-size: 17.5px;
  line-height: 2.05;
  white-space: pre-line;
  margin: 0;
  padding: 14px 16px 0;
}

.tanglish {
  margin: 0;
  padding: 10px 16px 14px;
  color: var(--muted);
  font-size: 13.5px;
  font-style: italic;
  line-height: 1.8;
  white-space: pre-line;
}

.actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}

.source { margin-left: auto; color: var(--rust-soft); font-size: 13px; text-decoration: none; }
.source:hover { text-decoration: underline; }

/* per-poem audio */
.play { font: inherit; font-size: 13.5px; cursor: pointer; border: 1px solid rgba(255,140,0,.55); background: rgba(255,140,0,.12); color: #ffb25e; border-radius: 999px; padding: 5px 14px; line-height: 1.5; transition: background .15s, color .15s; }
.play:hover { background: rgba(255,140,0,.28); color: #ffd9a8; }
.play.playing { background: #ff8c00; color: #1a1206; border-color: #ff8c00; }

footer {
  margin-top: 44px;
  padding-top: 18px;
  padding-bottom: 40px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

footer a { color: var(--rust-soft); }

::selection { background: rgba(232, 162, 107, 0.35); }

@media (max-width: 640px) {
  header { padding-top: 26px; }
  .grid { grid-template-columns: 1fr; gap: 16px; }
  nav label { margin-left: 0; width: 100%; }
  #search { width: 100%; }
  .avatar.big { width: 64px; height: 64px; font-size: 18px; }
}

/* v7: IG-profile grid + opened-post overlay */
body.locked { overflow: hidden; }

.grid {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.sq {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  cursor: pointer;
  padding: 14px;
  text-align: left;
  font-family: inherit;
  color: var(--ink);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: border-color .15s, background .15s;
}

.sq:hover { border-color: var(--rust); background: #262428; }

.sq-title {
  font-family: "Noto Serif Tamil", "Noto Serif", Georgia, serif;
  font-weight: 600;
  font-size: clamp(13px, 1.6vw, 17px);
  line-height: 1.7;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sq-foot {
  margin-top: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

.sq-num { font-size: 11.5px; color: var(--muted); font-variant-numeric: tabular-nums; }

.sq-badge {
  margin-left: auto;
  padding: 1px 7px;
  border: 1px solid var(--rust-soft);
  border-radius: 999px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--rust-soft);
}

/* opened post overlay */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.overlay[hidden] { display: none; }

.overlay-back {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 8, 0.78);
  backdrop-filter: blur(4px);
}

.post {
  position: relative;
  width: min(620px, 100%);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.post .close {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px 8px;
}

.post .close:hover { color: var(--ink); }

.post .ta { font-size: 20px; padding-top: 18px; }
.post .tanglish { font-size: 14px; }

.post-nav {
  display: flex;
  justify-content: space-between;
  padding: 10px 16px 14px;
  border-top: 1px solid var(--line);
}

.post-nav button {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
}

.post-nav button:hover:not(:disabled) { color: var(--ink); border-color: var(--rust); }
.post-nav button:disabled { opacity: 0.35; cursor: default; }

@media (max-width: 640px) {
  .grid { gap: 4px; }
  .sq { padding: 10px; }
  .sq-title { -webkit-line-clamp: 3; }
  .overlay { padding: 0; align-items: stretch; }
  .post { width: 100%; max-height: none; height: 100%; border-radius: 0; border: none; }
}
.post .card-top { padding-right: 44px; }

/* v8: text-filled grid tiles (like the Instagram grid) */
.sq {
  container-type: inline-size;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10% 8%;
  text-align: center;
  background: radial-gradient(120% 90% at 50% 40%, #232224 0%, #1a1a1b 70%, #151515 100%);
}
.sq:hover { background: radial-gradient(120% 90% at 50% 40%, #2a2729 0%, #201e20 70%, #1a1919 100%); }
.sq-text {
  font-family: "Noto Serif Tamil", "Noto Serif", Georgia, serif;
  font-weight: 600;
  color: var(--ink);
  font-size: clamp(10px, 6cqw, 20px);
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: break-word;
  width: 100%;
  min-width: 0;
  display: -webkit-box;
  -webkit-line-clamp: 8;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.sq-text.big { font-size: clamp(11px, 7.2cqw, 24px); -webkit-line-clamp: 6; }
.sq-text.small { font-size: clamp(10px, 5.3cqw, 18px); -webkit-line-clamp: 9; }
.sq-num {
  position: absolute;
  left: 7px;
  bottom: 5px;
  font-size: 10.5px;
  opacity: 0.8;
}
.sq-badge {
  position: absolute;
  top: 6px;
  right: 6px;
  margin: 0;
  font-size: 9px;
  background: rgba(22, 22, 22, 0.7);
}
@media (max-width: 640px) {
  .sq { padding: 13% 5% 12%; }
  .sq-text, .sq-text.big, .sq-text.small { font-size: 10px; overflow-wrap: anywhere; line-height: 1.5; -webkit-line-clamp: 5; }
  .sq-text.big { font-size: 11px; -webkit-line-clamp: 4; }
  .sq-num { font-size: 9px; left: 5px; bottom: 3px; }
  .sq-badge { font-size: 7.5px; padding: 0 5px; top: 4px; right: 4px; }
}

/* v9: play button on each grid tile */
.sq { padding-bottom: max(10%, 46px); }
.sq-play {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--rust);
  color: #fff6ee;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
  cursor: pointer;
  opacity: 0.92;
  transition: transform .15s, opacity .15s, background .15s;
  z-index: 2;
}
.sq-play svg { width: 16px; height: 16px; fill: currentColor; }
.sq-play:hover, .sq-play:focus-visible { opacity: 1; transform: scale(1.08); outline: none; }
.sq-play.playing { background: #e8843d; opacity: 1; box-shadow: 0 0 0 3px rgba(232, 132, 61, 0.35), 0 2px 8px rgba(0,0,0,.45); animation: sqpulse 1.6s ease-in-out infinite; }
@keyframes sqpulse { 50% { box-shadow: 0 0 0 6px rgba(232, 132, 61, 0.15), 0 2px 8px rgba(0,0,0,.45); } }
@media (max-width: 640px) {
  .sq { padding-bottom: 30px; padding-top: 18px; }
  .sq-play { width: 24px; height: 24px; right: 4px; bottom: 4px; }
  .sq-play svg { width: 12px; height: 12px; }
}
@media (max-width: 400px) {
  .sq-text, .sq-text.small { -webkit-line-clamp: 4; }
  .sq-text.big { -webkit-line-clamp: 3; }
}
